Look at the types of the two parts of parse
's definition separately.
parse :: [a] -> [b] -- both the []'s are lists of some (possibly different) type
parse [] = []
and
parse :: [Token] -> Int -- y, the function's return value, is an Int.
parse (x:xs) = case x of
Number y -> y
and you can see that while a ~ Token
works just fine, [b] ~ Int
doesn't work: an Int is not a list of something. (The error message is using a0
where I'm using b
.)
The way out of this is to think about what type you want parse
to return, and make sure all the parts of its definition match it. I'm not sure exactly what you want parse
to do, so I can't give a definite answer there.