summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs')
-rw-r--r--testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs44
1 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs
new file mode 100644
index 0000000000..4a79e69ed6
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/LongWayOverlapping.hs
@@ -0,0 +1,44 @@
+{-# LANGUAGE TypeFamilies, MultiParamTypeClasses
+ , FlexibleContexts, FlexibleInstances, UndecidableInstances
+ , TypeSynonymInstances, GeneralizedNewtypeDeriving
+ , OverlappingInstances
+ #-}
+
+module LongWayOverlapping where
+
+
+class M a where
+
+class M a => XMLG a
+
+instance M [a]
+
+instance XMLG [m] where -- Generates an implication wanted: forall m. M [m]
+
+class M a => EmbAsChild a b where
+ emb :: b -> [a]
+
+
+instance EmbAsChild [Char] Bool where
+ emb _ = emb 'c'
+
+
+ -- This one generates an unsolvable EmbAsChild [Char] Char
+
+-- Original problem is:
+-- [w] EmbAsChild [Char] Char
+-- [w] forall m. M [m]
+-- Now, by converting the wanted to given and pushing it inside the implication
+-- we have the following:
+-- [g] EmbAsChild [Char] Char
+-- [g] M [Char] <~~ The superclass of the first given!
+-- [w] M [m]
+-- And now OOPS we can't solve M [m] because we are supposed to delay our choice
+-- as much as possible!
+
+-- DV:
+-- One possible solution is to STOP PUSHING wanteds as givens inside an implication
+-- in a checking context. I think it's the best thing to do and I've implemented it.
+
+-- In inference mode that's ok and the error message is very comprehensible, see
+-- test case PushedInFlatsOverlap.hs