I have a custom datatype similar to:
data Token = Number Int
| Otherthings
I want to be able to use the "Number" in one way and other things in another. So I can successfully create a case statement like:
parse x = case x of
Number y -> y
Which then successfully takes:
let x = Number 7 in parse x
And evaluates to 7. However, when I try to change the "parse" function to be:
parse [] = []
parse (x:xs) = case x of
Number y -> y
I get the error:
Couldn't match expected type `[a0]' with actual type `Int'
In the expression: y
In a case alternative: Number y -> y
In the expression: case x of { Number y -> y }
Why doesn't this work this way and what's the proper way to approach this problem? Thank you much!