summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/boxy/Base1.hs
blob: 88e7e80f175d87f127959aa5c366de3318ef2e3d (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
{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags #-}

module Base1 where 
-- basic examples of impredicative instantiation of variables 

data MEither a b = MLeft a 
                 | MRight b 
                 | MEmpty

type Sid = forall a. a -> a 

-- no need for impredicativity 
test0 = MRight id 

-- requires impredicativity 
test1 :: Sid -> MEither Sid b
test1 fid = MLeft fid 

test2 :: MEither b Sid -> Maybe (Sid,Sid) 
test2 m = case (test1 id) of 
             MLeft x -> case m of 
                          MRight y -> Just (x,y) 
                          _ -> Nothing 
             _ -> Nothing

test3 :: MEither a b -> b
test3 (MRight x) = x 

test4 = test3 (test1 id)