
I think this is because "Tree" is a data type and not a data constructor.
According to your definition of Tree, Empty and Node are the constructors.
Node a (Node b (Node c Empty Empty) (Node d Empty Empty)) (Node e (Node f
Empty Empty) (Node g Empty Empty))
is a valid tree if a, b, c, d, e, f, g are integers.
Hope this helps.
--
Aditya.
On 10 March 2012 15:58, bahadýr altan
Hello everyone. I'm trying to write a code which works on binary trees. When I write code like this with a tree with empty nodes :
data Tree = Empty | Node Integer Tree Tree
function Node a (Node b Empty Empty) (Node c Empty Empty)
it works fine. But when I try to create a more generic code like this which could work with trees who don't have empty nodes in grandchild level :
function Node a (Node b Tree Tree) (Node c Tree Tree )
I get this error : Undefined data constructor "Tree"
Can you help me with creating more generic code please? Thanks
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners