summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/cgrun007.hs
blob: 317b921a42c2b4b9ff9840c404fd76d105c309bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
data Tree a = Leaf a | Branch (Tree a) (Tree a)

main = print (height our_tree)
    where
      our_tree :: Tree Int
      our_tree =
	Branch (Branch (Leaf 1) (Branch (Branch (Leaf 1) (Leaf 1)) (Leaf 1)))
	       (Branch (Leaf 1) (Leaf 1))


height :: Tree a -> Int

height (Leaf _)		= 1
height (Branch t1 t2)	= 1 + max (height t1) (height t2)