From bca164956e8e86e28fe2b3e36fbb9ce8a5d1a61d Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 9 Sep 2004 16:30:23 +0000 Subject: [project @ 2004-09-09 16:30:22 by simonpj] Add GADT tests; these will fail in the HEAD, but never mind --- testsuite/tests/ghc-regress/gadt/gadt4.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testsuite/tests/ghc-regress/gadt/gadt4.hs (limited to 'testsuite/tests/ghc-regress/gadt/gadt4.hs') diff --git a/testsuite/tests/ghc-regress/gadt/gadt4.hs b/testsuite/tests/ghc-regress/gadt/gadt4.hs new file mode 100644 index 0000000000..7a6bc06ac1 --- /dev/null +++ b/testsuite/tests/ghc-regress/gadt/gadt4.hs @@ -0,0 +1,18 @@ +{-# OPTIONS -fglasgow-exts #-} + +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 -- cgit v1.2.1