summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/indexed-types/should_compile/T12522b.hs20
-rw-r--r--testsuite/tests/indexed-types/should_compile/all.T1
-rw-r--r--testsuite/tests/indexed-types/should_fail/T12522a.hs21
-rw-r--r--testsuite/tests/indexed-types/should_fail/T12522a.stderr18
-rw-r--r--testsuite/tests/indexed-types/should_fail/all.T1
5 files changed, 61 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T12522b.hs b/testsuite/tests/indexed-types/should_compile/T12522b.hs
new file mode 100644
index 0000000000..75013823c9
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_compile/T12522b.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE TypeFamilyDependencies #-}
+{-# LANGUAGE TypeOperators #-}
+
+module T12522a where
+
+newtype I a = I a
+
+type family Curry (as :: [*]) b = f | f -> as b where
+ Curry '[] b = I b
+ Curry (a:as) b = a -> Curry as b
+
+data Uncurried (as :: [*]) b
+
+def :: Curry as b -> Uncurried as b
+def = undefined
+
+-- test2 :: Uncurried [Bool, Bool] Bool
+test2 = def $ \a b -> I $ a && b
diff --git a/testsuite/tests/indexed-types/should_compile/all.T b/testsuite/tests/indexed-types/should_compile/all.T
index 4eeb777d9c..eab93ac720 100644
--- a/testsuite/tests/indexed-types/should_compile/all.T
+++ b/testsuite/tests/indexed-types/should_compile/all.T
@@ -275,3 +275,4 @@ test('T11361a', normal, compile_fail, [''])
test('T11581', normal, compile, [''])
test('T12175', normal, compile, [''])
test('T12522', normal, compile, [''])
+test('T12522b', normal, compile, [''])
diff --git a/testsuite/tests/indexed-types/should_fail/T12522a.hs b/testsuite/tests/indexed-types/should_fail/T12522a.hs
new file mode 100644
index 0000000000..eb855f4171
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T12522a.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE TypeFamilyDependencies #-}
+{-# LANGUAGE TypeOperators #-}
+
+module T12522a where
+
+newtype I a = I a
+
+type family Curry (as :: [*]) b = f | f -> as b where
+ Curry '[] b = I b
+ Curry (a:as) b = a -> Curry as b
+
+data Uncurried (as :: [*]) b
+
+def :: Curry as b -> Uncurried as b
+def = undefined
+
+-- test :: Uncurried [Int, String] String
+test = def $ \n s -> I $ show n ++ s
+
diff --git a/testsuite/tests/indexed-types/should_fail/T12522a.stderr b/testsuite/tests/indexed-types/should_fail/T12522a.stderr
new file mode 100644
index 0000000000..7356791a97
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T12522a.stderr
@@ -0,0 +1,18 @@
+
+T12522a.hs:20:26: error:
+ • Ambiguous type variable ‘a0’ arising from a use of ‘show’
+ prevents the constraint ‘(Show a0)’ from being solved.
+ Relevant bindings include
+ n :: a0 (bound at T12522a.hs:20:15)
+ test :: Uncurried '[a0, [Char]] [Char] (bound at T12522a.hs:20:1)
+ Probable fix: use a type annotation to specify what ‘a0’ should be.
+ These potential instances exist:
+ instance Show Ordering -- Defined in ‘GHC.Show’
+ instance Show Integer -- Defined in ‘GHC.Show’
+ instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
+ ...plus 22 others
+ ...plus five instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ • In the first argument of ‘(++)’, namely ‘show n’
+ In the second argument of ‘($)’, namely ‘show n ++ s’
+ In the expression: I $ show n ++ s
diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T
index 1aaa07e5b9..f4f8c8d2c9 100644
--- a/testsuite/tests/indexed-types/should_fail/all.T
+++ b/testsuite/tests/indexed-types/should_fail/all.T
@@ -139,3 +139,4 @@ test('T11136', normal, compile_fail, [''])
test('T7788', normal, compile_fail, [''])
test('T11450', normal, compile_fail, [''])
test('T12041', normal, compile_fail, [''])
+test('T12522a', normal, compile_fail, [''])