[Haskell] help with some basic code that doesn't work
Karl Hasselström
kha at treskal.com
Tue Feb 8 03:14:40 EST 2005
On 2005-02-07 20:36:55 +0000, pablo daniel rey wrote:
> data Dir = Left | Right | Up | Down
> data Piece = Vertical | Horizontal | CodeA | CodeB
>
> the error i get :
>
> Instances of (Eq Dir, Eq Piece) required for definition of chgDir
You try to compare Dir and Piece values without having told Haskell
how the comparison should work. Haskell doesn't provide a default
comparison funcition even for the really obvious cases like this,
unless you tell it to using the "deriving" keyword:
data Bool = False | True deriving (Eq,Ord,Show,Read)
In your case, all you need is Eq, so you can skip the parentheses.
--
Karl Hasselström, kha at treskal.com
www.treskal.com/kalle
More information about the Haskell
mailing list