summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs
diff options
context:
space:
mode:
authorDimitrios.Vytiniotis <dimitris@microsoft.com>2012-04-10 02:12:13 +0100
committerDimitrios.Vytiniotis <dimitris@microsoft.com>2012-04-10 02:12:13 +0100
commit6e369fd23fec64204893ef643f14071950e2b651 (patch)
tree4b94b99c2ce45cc91cc54625ef8f8de69f24d5e8 /testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs
parenta647d30c96af6bca4e0dfb2ea139cdc8dc3156e2 (diff)
downloadhaskell-6e369fd23fec64204893ef643f14071950e2b651.tar.gz
Adding test case for polytype decomposition in the constraint solver.
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs')
-rw-r--r--testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs b/testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs
new file mode 100644
index 0000000000..69e4fb31c7
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/PolytypeDecomp.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE TypeFamilies, LiberalTypeSynonyms, ImpredicativeTypes #-}
+module PolyTypeDecomp where
+
+
+{- The purpose of this test is to check if decomposition of wanted
+ equalities in the /constraint solver/ (vs. the unifier) works properly.
+ Unfortunately most equalities between polymorphic types are converted to
+ implication constraints early on in the unifier, so we have to make things
+ a bit more convoluted by introducing the myLength function. The wanted
+ constraints we get for this program are:
+ [forall a. Maybe a] ~ Id alpha
+ [forall a. F [a]] ~ Id alpha
+ Which, /after reactions/ should create a fresh implication:
+ forall a. Maybe a ~ F [a]
+ that is perfectly soluble.
+-}
+
+type family F a
+type instance F [a] = Maybe a
+
+type family Id a
+type instance Id a = a
+
+f :: [forall a. F [a]]
+f = undefined
+
+
+g :: [forall a. Maybe a] -> Int
+g x = myLength [x,f]
+
+myLength :: [Id a] -> Int
+myLength = undefined