Testsuite error message changes
[ghc.git] / testsuite / tests / indexed-types / should_fail / ExtraTcsUntch.hs
1 {-# LANGUAGE TypeFamilies, FunctionalDependencies, FlexibleContexts, GADTs, ScopedTypeVariables #-}
2
3 module ExtraTcsUntch where
4
5
6 class C x y | x -> y where
7 op :: x -> y -> ()
8
9 instance C [a] [a]
10
11 type family F a :: *
12
13 h :: F Int -> ()
14 h = undefined
15
16 data TEx where
17 TEx :: a -> TEx
18
19
20
21 f x =
22 let g1 :: forall b. b -> ()
23 g1 _ = h [x]
24
25 g2 z = case z of TEx y -> (h [[undefined]], op x [y])
26
27 in (g1 '3', g2 undefined)
28
29
30 {- This example comes from Note [Extra TcS Untouchables] in TcSimplify. It demonstrates
31 why when floating equalities out of an implication constraint we must record the free
32 variables of the equalities as untouchables. With GHC 7.4.1 this program gives a Core
33 Lint error because of an existential escaping.
34
35 assuming x:beta
36
37 forall b. F Int ~ [beta] (from g1)
38 forall a. F Int ~ [[alpha]], C beta [a] (from g2)
39
40 -}
41
42
43
44
45 {- Assume x:beta
46 From g1 we get [W] (forall b. F Int ~ [beta])
47
48 From g2 we get [W] (forall c. 0 => F Int ~ [[alpha]] /\ C beta [c])
49 (g2 is not generalised; the forall comes from the TEx pattern)
50
51 approximateWC then gives the candidate constraints to quantify
52 F Int ~ [beta], F Int ~ [[alpha']]
53
54 (alpha' is the promoted version of alpha)
55
56 Now decide inferred sig for f :: F Int ~ [beta] => beta -> blah
57 since beta is mentioned in tau-type for f but alpha' is not
58
59 Perhaps this is a stupid constraint to generalise over (we don't
60 generalise over (C Int).
61 -}