Haskell Enum比较

时间:2015-11-18 12:07:28

标签: haskell enums

我定义了一个枚举:

data Direction = Clockwise | CounterClockwise deriving (Enum)

变量'方向'有类型'方向'。在进行以下比较时:

direction == Clockwise

我收到此错误:

  No instance for (Eq OrbitDirection) arising from a use of `=='
  In the expression: direction == Clockwise

1 个答案:

答案 0 :(得分:7)

这很简单:将Eq实例添加到派生实例列表中:

data Direction = Clockwise | CounterClockwise deriving (Enum, Eq)