summaryrefslogtreecommitdiff
path: root/testsuite/tests/gadt/gadt4.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/gadt/gadt4.hs')
-rw-r--r--testsuite/tests/gadt/gadt4.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/gadt4.hs b/testsuite/tests/gadt/gadt4.hs
new file mode 100644
index 0000000000..0d78135597
--- /dev/null
+++ b/testsuite/tests/gadt/gadt4.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE GADTs #-}
+
+module Main where
+
+data Term a where
+ Lit :: Int -> Term Int
+ IsZero :: Term Int -> Term Bool
+ If :: Term Bool -> Term a -> Term a -> Term a
+
+
+eval :: Term a -> a
+eval (Lit n) = n
+eval (IsZero t) = eval t == 0
+eval (If t1 t2 t3) = if eval t1 then eval t2 else eval t3
+
+term = If (IsZero (Lit 1)) (Lit 2) (Lit 3)
+
+main = print (eval term) \ No newline at end of file