[project @ 2001-08-22 11:45:06 by sewardj]
[ghc-hetmet.git] / ghc / tests / codeGen / should_run / cg007.hs
1 data Tree a = Leaf a | Branch (Tree a) (Tree a)
2
3 main = print (height our_tree)
4     where
5       our_tree :: Tree Int
6       our_tree =
7         Branch (Branch (Leaf 1) (Branch (Branch (Leaf 1) (Leaf 1)) (Leaf 1)))
8                (Branch (Leaf 1) (Leaf 1))
9
10
11 height :: Tree a -> Int
12
13 height (Leaf _)         = 1
14 height (Branch t1 t2)   = 1 + max (height t1) (height t2)