summaryrefslogtreecommitdiff
path: root/testsuite/tests/polykinds/T9574.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-11-28 17:23:08 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-11-28 17:36:14 +0000
commit171101beca39befde191baff5027c417bcc709ee (patch)
tree7495d34da2d5f579601ff19d0f32fcc79dc7f516 /testsuite/tests/polykinds/T9574.hs
parent2eecf348a62c47abd2f5de5f7eac5f7a3a779107 (diff)
downloadhaskell-171101beca39befde191baff5027c417bcc709ee.tar.gz
Kind variables in RHS of an associated type instances should be bound on LHS
This patche fixes Trac #9574. The previous Note [Renaming associated types] in RnTypes appears to me to be wrong; it confused class and instance declarations. I have: * Treated kind and type variables uniformly. Both must be bound on the LHS of an associated type instance. Eg instance C ('KProxy :: KProxy o) where type F 'KProxy = NatTr (Proxy :: o -> *) is illegal because 'o' is not bound on the LHS of the instance. * Moved the Note to RnSource and fixed it up This improves the error message from T7938. However it made the code in T6118 incorrect. We had: instance SingE (a :: Maybe k) where type Demote a = Maybe (Demote (Any :: k)) and that is now rejected, rightly I think.
Diffstat (limited to 'testsuite/tests/polykinds/T9574.hs')
-rw-r--r--testsuite/tests/polykinds/T9574.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/polykinds/T9574.hs b/testsuite/tests/polykinds/T9574.hs
new file mode 100644
index 0000000000..e806e2a6a2
--- /dev/null
+++ b/testsuite/tests/polykinds/T9574.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE PolyKinds, DataKinds, TypeFamilies, ScopedTypeVariables, GADTs, RankNTypes #-}
+module T9574 where
+
+data KProxy (t :: *) = KProxy
+data Proxy p
+
+class Funct f where
+ type Codomain f :: *
+
+instance Funct ('KProxy :: KProxy o) where
+ type Codomain 'KProxy = NatTr (Proxy :: o -> *)
+
+data NatTr (c :: o -> *) where
+ M :: (forall (a :: o). Proxy a) -> NatTr (c :: o -> *)
+
+p :: forall (c :: o -> *). NatTr c
+p = M t where
+ M t = undefined :: Codomain ('KProxy :: KProxy o)