diff options
Diffstat (limited to 'testsuite/tests/gadt/scoped.hs')
-rw-r--r-- | testsuite/tests/gadt/scoped.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/scoped.hs b/testsuite/tests/gadt/scoped.hs new file mode 100644 index 0000000000..cafa738697 --- /dev/null +++ b/testsuite/tests/gadt/scoped.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE GADTs, ScopedTypeVariables #-} + +-- Tests for scoped type variables and GADTs + +module GADT where + +data C x y where + C :: a -> C a a + +data D x y where + D :: C b c -> D a c + +------- All these should be ok + +-- Rejected! +g1 :: forall x y . C x y -> () +-- C (..) :: C x y +-- Inside match on C, x=y +g1 (C (p :: y)) = () + +-- OK! +g2 :: forall x y . C x y -> () +-- C (..) :: C x y +-- Inside match on C, x=y +g2 (C (p :: x)) = () + +-- Rejected! +g3 :: forall x y . D x y -> () +-- D (..) :: D x y +-- C (..) :: C sk y +-- sk = y +-- p :: sk +g3 (D (C (p :: y))) = () |