summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-05-26 11:58:03 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2018-05-26 11:58:03 -0400
commit9ed7e8d6a31b96ea2f171f1ad064294ee618b032 (patch)
tree92fe4f9ee3375aab282d65d9a2bd84a171a7af32
parent00f7e2850396c69938ddb017bc8d87ca1ecd882a (diff)
downloadhaskell-9ed7e8d6a31b96ea2f171f1ad064294ee618b032.tar.gz
Add regression test for #14246
-rw-r--r--testsuite/tests/indexed-types/should_fail/T14246.hs23
-rw-r--r--testsuite/tests/indexed-types/should_fail/T14246.stderr24
-rw-r--r--testsuite/tests/indexed-types/should_fail/all.T1
3 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/T14246.hs b/testsuite/tests/indexed-types/should_fail/T14246.hs
new file mode 100644
index 0000000000..cf947e816e
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T14246.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE RankNTypes, GADTs, TypeOperators, PolyKinds, DataKinds, TypeFamilies, AllowAmbiguousTypes, UndecidableInstances, TypeInType #-}
+
+module T14246 where
+
+import Data.Kind -- necessary for *
+
+data Nat = Z | S Nat
+
+data Vect :: Nat -> Type -> Type where
+ Nil :: Vect Z a
+ Cons :: a -> Vect n a -> Vect (S n) a
+
+data Label a = Label a
+
+data L
+
+type family KLN (n :: k) :: Nat where
+ KLN (f :: v -> k) = S (KLN (forall t. f t))
+ KLN (f :: *) = Z
+
+type family Reveal (n :: k) (l :: Vect (KLN n) L) :: * where
+ Reveal (f :: v -> k) (Cons (Label (t :: v)) l) = Reveal (f t) l
+ Reveal (a :: *) Nil = a
diff --git a/testsuite/tests/indexed-types/should_fail/T14246.stderr b/testsuite/tests/indexed-types/should_fail/T14246.stderr
new file mode 100644
index 0000000000..0f0a3e579d
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T14246.stderr
@@ -0,0 +1,24 @@
+
+T14246.hs:18:5: error:
+ • Illegal polymorphic type: forall (t :: v). f t
+ • In the equations for closed type family ‘KLN’
+ In the type family declaration for ‘KLN’
+
+T14246.hs:22:27: error:
+ • Expected kind ‘Vect (KLN f) L’,
+ but ‘Cons (Label (t :: v)) l’ has kind ‘Vect ('S (KLN (f t))) *’
+ • In the second argument of ‘Reveal’, namely
+ ‘(Cons (Label (t :: v)) l)’
+ In the type family declaration for ‘Reveal’
+
+T14246.hs:22:67: error:
+ • Expected kind ‘Vect (KLN (f t)) L’,
+ but ‘l’ has kind ‘Vect (KLN (f t)) *’
+ • In the second argument of ‘Reveal’, namely ‘l’
+ In the type ‘Reveal (f t) l’
+ In the type family declaration for ‘Reveal’
+
+T14246.hs:23:21: error:
+ • Expected kind ‘Vect (KLN a) L’, but ‘Nil’ has kind ‘Vect 'Z L’
+ • In the second argument of ‘Reveal’, namely ‘Nil’
+ In the type family declaration for ‘Reveal’
diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T
index 80ea5dafa9..ef5eee2e8b 100644
--- a/testsuite/tests/indexed-types/should_fail/all.T
+++ b/testsuite/tests/indexed-types/should_fail/all.T
@@ -141,5 +141,6 @@ test('T14033', normal, compile_fail, [''])
test('T14045a', normal, compile_fail, [''])
test('T14175', normal, compile_fail, [''])
test('T14179', normal, compile_fail, [''])
+test('T14246', normal, compile_fail, [''])
test('T14369', normal, compile_fail, [''])
test('T15172', normal, compile_fail, [''])