diff options
Diffstat (limited to 'testsuite/tests/gadt/records.hs')
-rw-r--r-- | testsuite/tests/gadt/records.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/records.hs b/testsuite/tests/gadt/records.hs new file mode 100644 index 0000000000..e28add3fb6 --- /dev/null +++ b/testsuite/tests/gadt/records.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE GADTs #-} + +-- Tests record syntax for GADTs + +module Main where + +data T a where + T1 :: { x :: a, y :: b } -> T (a,b) + T2 :: { x :: a } -> T (a,b) + T3 :: { z :: Int } -> T Bool + +f xv yv = T1 { x = xv, y = yv } + +g :: T a -> T a +g (T1 {x=xv, y=yv}) = T2 { x = xv } + +-- h :: Num a => T a any -> a +h v = x v + 1 + +main = do { let t1 = T1 { y = "foo", x = 4 } + t2 = g t1 + ; print (h (f 8 undefined)) + ; print (h t2) + } +
\ No newline at end of file |