To allow deriving poly-kinded Generic1 instances

Fumiaki Kinoshita fumiexcel at gmail.com
Tue Oct 12 13:36:14 UTC 2021


I was hacking GHC to see if it's able to derive Generic1 instance for
datatypes with kind (Type -> Type) -> Type by omitting some checks. I
noticed that the type parameter is substituted by GHC.Types.Any, preventing
higher-kinded instances from typechecking. I found a comment implying that
this is intentional; in GHC.Tc.Deriv.Generic.hs:977,

Alternatively, we could have avoided this problem by expanding all type
synonyms on the RHSes of Rep1 instances. But we might blow up the size of
these types even further by doing this, so we choose not to do so.

It wasn't obvious to me if binding a parameter in the type synonym instance
declaration of Rep1 cause problems, because that's what I'd do if I were to
define an instance by hand. Is there any offending example?

I'm also trying to make such change myself (it doesn't add a type parameter
and I'm not sure why)
https://gitlab.haskell.org/fumieval/ghc/-/commit/bfe7766af80d90590b6b032d1839694b82b8919a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20211012/cab6ddba/attachment.html>


More information about the ghc-devs mailing list