Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell Enum Comparison

Tags:

enums

haskell

I've defined an enum:

data Direction = Clockwise | CounterClockwise deriving (Enum)

Variable 'direction' has type 'Direction'. When doing the following comparison:

direction == Clockwise

I'm getting this error:

  No instance for (Eq OrbitDirection) arising from a use of `=='
  In the expression: direction == Clockwise
like image 602
JamesFrost Avatar asked Nov 18 '15 12:11

JamesFrost


1 Answers

This is as simple as it gets: add the Eq instance to the derived instances list:

data Direction = Clockwise | CounterClockwise deriving (Enum, Eq)
like image 60
Bartek Banachewicz Avatar answered Nov 11 '22 09:11

Bartek Banachewicz