summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/T3409.hs
blob: b584fe1f1f72a3edba3a1a0c532e9a0625ca0da9 (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
43
44
45
46
47
48
49
50
51
52
53
{-# LANGUAGE  ExistentialQuantification, TypeFamilies #-}

-- Tests a nasty case where 'exprType' or 'coreAltsType' can
-- return a type that mentions an out-of-scope type variable
-- because of a type synonym that discards one of its arguments
--
-- See Note [Existential variables and silly type synonyms] 
-- in CoreUtils

-- In GHC 6.10, both tests below (independently) give Lint errors

module T3409 where


--------------------------
-- Simpler version not involving type families

data T = forall a. T a (Funny a)
type Funny a = Bool

f :: T -> Bool
f (T x n) = n


--------------------------
-- Cut down version of the original report

newtype Size s = Size Int

data ArrayS d e = ArrayS d e

data Array1 e = forall s . Array1 (Size s) (ArrayS (Size s) e)
-- Array1 :: forall e s. Size s -> ArrayS (Size s) e -> Array1 e

copy ::  Int -> Array1 a -> Array1 a
copy _ (Array1 s a) = Array1 s $ (ArrayS s (bang a))
  -- Array1 s :: ArrayS (Size s) a -> Array1 a

  -- s :: Size s
  -- a :: ArrayS (Size s) a
  -- ArrayS :: Size s -> a -> ArrayS (Size s) a
  -- i :: AccessIx (ArrayS (Size s) a) = Ix s
  -- bang a :: AccessResult (ArrayS (Size s) a) = a

  -- ArrayS s (bang a) :: ArrayS (Size s) (AccessResult (ArrayS (Size s) a))

class Access a where
    type AccessResult a
    bang :: a -> AccessResult a

instance Access (ArrayS d a) where
    type AccessResult (ArrayS d a) = a
    bang = error "urk"