summaryrefslogtreecommitdiff
path: root/testsuite/tests/gadt/scoped.hs
blob: ea321a53c45096f1a112a89d58272a2a2dd2cf92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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))) = ()