[Haskell-beginners] Re: about the concatenation on a tree

Thomas Davie tom.davie at gmail.com
Thu Jan 1 04:58:26 EST 2009

> hi Bob,
> I believe the type of foldTree is implementable, but what confuses  
> me is
> the output example:
>> concatT (Leaf t) = t
>> concatT (Branch (Leaf t1) (Leaf t2)) = Branch t1 t2
> they seem to be inconsistent with the type of concatT which return a  
> Tree only, but in the Leaf case, a atomic value is returned?
> anything important I am missing?

You need to remember what type is stored in that Leaf – remember that  
this is a Tree (Tree a) – i.e. the variable t in the line above has  
the type Tree a.


More information about the Beginners mailing list