Merge branch 'master' of https://github.com/ghc/testsuite
[ghc.git] / testsuite / tests / typecheck / should_fail / FrozenErrorTests.hs
1 {-# LANGUAGE RankNTypes, GADTs, TypeFamilies #-}
2 module Test where
3
4
5 data T a where
6 MkT :: a -> T a
7 MkT3 :: forall a. (a ~ Bool) => T a
8
9 -- Occurs checks in givens
10 foo :: forall a. (a ~ T a) => a -> a
11 foo x = x
12
13 -- Mismatches in givens
14 bloh :: T Int -> ()
15 bloh x = case x of
16 MkT3 -> ()
17
18 type family F a b
19 type family G a b
20 type instance F a Bool = a
21 type instance G a Char = a
22
23 goo1 :: forall a b. (F a b ~ [a]) => b -> a -> a
24 goo1 = undefined
25
26 goo2 :: forall a. G a Char ~ [Int] => a -> a
27 goo2 = undefined
28
29 -- Just an occurs check
30 test1 = goo1 False undefined
31
32 -- A frozen occurs check, now transformed to decomposition error
33 test2 = goo2 (goo1 False undefined)
34 test3 = goo1 False (goo2 undefined)
35
36
37 -- A frozen occurs check, now transformed to both a decomposition and occurs check
38 data M a where
39 M :: M a
40 data T2 a b where
41 T2 :: T2 a b
42
43 goo3 :: forall a b. F a b ~ T2 (M a) a => b -> a -> a
44 goo3 = undefined
45
46 goo4 :: forall a c. G a Char ~ T2 (T2 c c) c => a -> a
47 goo4 = undefined
48
49 test4 = goo4 (goo3 False undefined)
50 test5 = goo3 False (goo4 undefined)
51
52
53