Hi, Haskellers and Haskellettes,
I played with Haskell for quite some time, but there is such a concept of classes that I cannot understand. In the following example, I have an ExprTree data ExprTree
data Val a = Num a | Var String deriving (Eq, Ord, Show) data ExprTree = Leaf {lab::Label, val::(Val a)=> a} | Node {lab::Label, fun::Fun, lBranch::ExprTree, rBranch::ExprTree} deriving(Eq,Ord)
that leads to
Type constructor `Val' used as a class In the definition of data constructor `Leaf' In the data type declaration for `ExprTree'
I also tried
data ExprTree' = Leaf {lab::Label, val::Val} ...
but a random change in type signature is neither sound nor effective nor enlightening.
now, as far as I know, Num a denotes something from the Num class, but it is not an instance of a data type - and does not allow me to compile. So what I need to do to make ExprTree correct.
Thanks in advance for the tips and ideas!
Edit
1) Thanks for the quick answers!
2) I changed val::(Val a)=>a to val::Val a
I had something similar, but then an error occurs: Not in scope type variable a do you have any additional tips?