summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/cgrun007.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/codeGen/should_run/cgrun007.hs')
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun007.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/cgrun007.hs b/testsuite/tests/codeGen/should_run/cgrun007.hs
new file mode 100644
index 0000000000..317b921a42
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/cgrun007.hs
@@ -0,0 +1,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)