summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/typecheck/should_compile/T1123.hs
blob: a9a7d965e31945a952e40bed93d0a9da3abbf65b (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
34
35
36
37
38
39
40
41
42
{-# LANGUAGE RankNTypes #-}

module Bug where

data T a = MkT

out :: forall a. T a -> ()
out MkT = ()

inHoisted :: forall r. () -> (forall a. T a -> r) -> r
inHoisted _ foo = foo MkT

inUnhoisted :: () -> forall r. (forall a. T a -> r) -> r
inUnhoisted _ foo = foo MkT

testHoisted :: ()
testHoisted = inHoisted () out

testUnhoisted :: ()
testUnhoisted = inUnhoisted () out


----------------

data A s = A { unA :: () }

runA1 :: (forall s. A s) -> ()
runA1 a = unA a

-- doesn't work :(
runA2 :: (forall s. A s) -> ()
runA2 (A a) = a

runA3 :: (forall s. A s) -> ()
runA3 a = case a of A x -> x

runA4 :: (forall s. A s) -> ()
runA4 a = let A x = a in x

runA5 :: (forall s. A s) -> ()
runA5 a = go a
  where go (A a) = a