GHC Trac Home
GHC Git Repos
Report a bug
Mailing Lists & IRC
The GHC Team
GHC Status Info
Tickets I Created
Patches for review
New Feature Req
side by side
lines around each change
Show the changes in full context
White space changes
Dec 20, 2011 1:47:06 PM (
This page gives additional implementation details for the `-XPolyKinds` flag. The grand design is described in the paper [http://dreixel.net/research/pdf/ghp.pdf Giving Haskell a Promotion]. Most of the work has been done and merged into GHC 7.4.1. The relevant user documentation is in [the user's guide (add link when it's up)] and on the [http://haskell.org/haskellwiki/GHC/Kinds Haskell wiki page]. What still doesn't work, or doesn't work correctly, is described here.
= Explicit kind variables =
Since the core language has all the support for kind variables, this shouldn't be too hard.
= Kind defaulting in type families =
At the moment, when you define a type family without `-XPolyKinds` like this:
type family F a
it gets kind `* -> *`. There are no constraints on the kind of `a`, so we
default it to `*`. We also default the return kind of `F` to `*`.
The same happens for data families, and also for plain datatypes with phantom
When you turn `-XPolyKinds` on, however, we currently give `F` the kind
`forall (k :: BOX). k -> *`. This is unsatisfactory for two reasons:
1. The behaviour of kind generalisation changes when we turn `-XPolyKinds` on,
even though it doesn't really have to. We could still default to `*` unless
you give a kind signature. So if you want `F` to be kind polymorphic, you
should write `type family F (a :: k)`. This, of course, requires supporting
[GhcKinds#Explicitkindvariables explicit kind variables].
2. Unlike the parameters, however, the return kind of `F` is defaulted to `*`.
This seems rather arbitrary. We should either generalise both arguments and
return kind, or default both. In case we choose to default, the more
general kind can be obtained by giving a signature:
type family F (a :: k1) :: k2
'''Future work:''' do more consistent kind defaulting.
= [http://hackage.haskell.org/trac/ghc/ticket/5682 #5682] (proper handling of infix promoted constructors) =
= Kind synonyms (from type synonym promotion) =