summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/cgrun007.hs
blob: 841869524a202fb92448815baa86c71051318ccc (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)