[GHC] #11357: Regression when deriving Generic1 on poly-kinded data family
GHC
ghc-devs at haskell.org
Tue Jan 5 23:52:18 UTC 2016
#11357: Regression when deriving Generic1 on poly-kinded data family
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner:
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 8.1
(CodeGen) |
Keywords: Generics, | Operating System: Unknown/Multiple
TypeInType |
Architecture: | Type of failure: GHC rejects
Unknown/Multiple | valid program
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
On GHC 7.10.3, the following code compiles:
{{{#!hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module ProxyFam where
import GHC.Generics (Generic1)
data family ProxyFam (a :: k)
data instance ProxyFam (a :: k) = ProxyCon deriving Generic1
}}}
But on GHC 8.1, it fails:
{{{
$ /opt/ghc/head/bin/ghc ProxyFam.hs
[1 of 1] Compiling ProxyFam ( ProxyFam.hs, ProxyFam.o )
ProxyFam.hs:10:53: error:
• Can't make a derived instance of ‘Generic1 ProxyFam’:
ProxyFam must not be instantiated; try deriving `ProxyFam k a'
instead
• In the data instance declaration for ‘ProxyFam’
}}}
I'm not sure what exactly is going on here, but I have a hunch. The
`Generic1` typeclass is of kind `* -> *`, which means that in a `Generic1
ProxyFam` instance, the kind of `a` is instantiated to `*`.
Curiously, though, the same error does ''not'' appear when `deriving
Generic` for a normal datatype (e.g., `data ProxyFam (a :: k) = ProxyCon
deriving Generic1`).
Richard, I'm stuck as to how to fix this. I suspect this was triggered by
`-XTypeInType`-related changes, specifically,
[http://git.haskell.org/ghc.git/blobdiff/6e56ac58a6905197412d58e32792a04a63b94d7e..6746549772c5cc0ac66c0fce562f297f4d4b80a2:/compiler/typecheck/TcGenGenerics.hs
this change]:
{{{#!diff
diff --git a/compiler/typecheck/TcGenGenerics.hs
b/compiler/typecheck/TcGenGenerics.hs
index 2c5b80e..fb18517 100644 (file)
--- a/compiler/typecheck/TcGenGenerics.hs
+++ b/compiler/typecheck/TcGenGenerics.hs
@@ -147,7 +146,7 @@ canDoGenerics tc tc_args
--
-- Data family indices can be instantiated; the `tc_args` here
are
-- the representation tycon args
- (if (all isTyVarTy (filterOut isKind tc_args))
+ (if (all isTyVarTy (filterOutInvisibleTypes tc tc_args))
then IsValid
else NotValid (tc_name <+> text "must not be
instantiated;" <+>
text "try deriving `" <> tc_name <+>
tc_tys <>
}}}
What exactly does `filterOutInvisibleTypes` do?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11357>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list