Haskell Enum Comparison

I defined the enumeration:

data Direction = Clockwise | CounterClockwise deriving (Enum)

The variable 'direction' is of type 'Direction'. When performing the following comparison:

direction == Clockwise

I get this error:

  No instance for (Eq OrbitDirection) arising from a use of `=='
  In the expression: direction == Clockwise
+4
source share
1 answer

It's as simple as it gets: add the instance Eqto the list of derived instances:

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

Source: https://habr.com/ru/post/1616363/


All Articles