More tests for Trac #12522
authorSimon Peyton Jones <simonpj@microsoft.com>
Mon, 10 Oct 2016 12:57:01 +0000 (13:57 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Mon, 10 Oct 2016 12:57:01 +0000 (13:57 +0100)
These ones test the variations in coment:15 of the ticket

testsuite/tests/indexed-types/should_compile/T12522b.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/indexed-types/should_fail/T12522a.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T12522a.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/all.T

diff --git a/testsuite/tests/indexed-types/should_compile/T12522b.hs b/testsuite/tests/indexed-types/should_compile/T12522b.hs
new file mode 100644 (file)
index 0000000..7501382
--- /dev/null
@@ -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
index 4eeb777..eab93ac 100644 (file)
@@ -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 (file)
index 0000000..eb855f4
--- /dev/null
@@ -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 (file)
index 0000000..7356791
--- /dev/null
@@ -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
index 1aaa07e..f4f8c8d 100644 (file)
@@ -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, [''])