Name: Anonymous 2010-02-28 4:31
Does anyone why this HASKAL code won't compile?
gives me
I don't see any other opportunity to "clear it up" using extra annotations or whatnot, so...
data Stack a = MkStack a (Stack a) | Null
push :: a -> Stack a -> Stack a
push a stack = MkStack a stack
pop :: Stack a -> Stack a
pop Null = Null
pop (MkStack a stacks) = stacks
instance Eq (Stack a) where
Null == Null = True
Null == (MkStack _1 _2) = False
(MkStack _1 _2) == Null = False
(MkStack x xs) == (MkStack y ys) = (x == y) && (xs == ys)gives me
\home\anus\haskal\peyote-joints.hs:14:38:
Could not deduce (Eq a) from the context (Eq (Stack a))
arising from a use of `==' at C:\stack.hs:14:38-43
Possible fix: add (Eq a) to the context of the instance declaration
In the first argument of `(&&)', namely `(x == y)'
In the expression: (x == y) && (xs == ys)
In the definition of `==':
(MkStack x xs) == (MkStack y ys) = (x == y) && (xs == ys)I don't see any other opportunity to "clear it up" using extra annotations or whatnot, so...