Testsuite: delete Windows line endings [skip ci] (#11631)
[ghc.git] / testsuite / tests / typecheck / should_fail / LongWayOverlapping.hs
1 {-# LANGUAGE TypeFamilies, MultiParamTypeClasses
2 , FlexibleContexts, FlexibleInstances, UndecidableInstances
3 , TypeSynonymInstances, GeneralizedNewtypeDeriving
4 #-}
5
6 module LongWayOverlapping where
7
8
9 class M a where
10
11 class M a => XMLG a
12
13 instance M [a]
14
15 instance XMLG [m] where -- Generates an implication wanted: forall m. M [m]
16
17 class M a => EmbAsChild a b where
18 emb :: b -> [a]
19
20
21 instance EmbAsChild [Char] Bool where
22 emb _ = emb 'c'
23
24
25 -- This one generates an unsolvable EmbAsChild [Char] Char
26
27 -- Original problem is:
28 -- [w] EmbAsChild [Char] Char
29 -- [w] forall m. M [m]
30 -- Now, by converting the wanted to given and pushing it inside the implication
31 -- we have the following:
32 -- [g] EmbAsChild [Char] Char
33 -- [g] M [Char] <~~ The superclass of the first given!
34 -- [w] M [m]
35 -- And now OOPS we can't solve M [m] because we are supposed to delay our choice
36 -- as much as possible!
37
38 -- DV:
39 -- One possible solution is to STOP PUSHING wanteds as givens inside an implication
40 -- in a checking context. I think it's the best thing to do and I've implemented it.
41
42 -- In inference mode that's ok and the error message is very comprehensible, see
43 -- test case PushedInFlatsOverlap.hs