Changes between Version 25 and Version 26 of GhcKinds

Dec 20, 2011 1:47:06 PM (4 years ago)



  • GhcKinds

    v25 v26  
    55This page gives additional implementation details for the `-XPolyKinds` flag. The grand design is described in the paper [ 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 [ Haskell wiki page]. What still doesn't work, or doesn't work correctly, is described here.
    78= Explicit kind variables =
    1819Since the core language has all the support for kind variables, this shouldn't be too hard.
    2022= Kind defaulting in type families =
     24At the moment, when you define a type family without `-XPolyKinds` like this:
     26type family F a
     28it gets kind `* -> *`. There are no constraints on the kind of `a`, so we
     29default it to `*`. We also default the return kind of `F` to `*`.
     30The same happens for data families, and also for plain datatypes with phantom
     33When you turn `-XPolyKinds` on, however, we currently give `F` the kind
     34`forall (k :: BOX). k -> *`. This is unsatisfactory for two reasons:
     36 1. The behaviour of kind generalisation changes when we turn `-XPolyKinds` on,
     37    even though it doesn't really have to. We could still default to `*` unless
     38    you give a kind signature. So if you want `F` to be kind polymorphic, you
     39    should write `type family F (a :: k)`. This, of course, requires supporting
     40    [GhcKinds#Explicitkindvariables explicit kind variables].
     42  2. Unlike the parameters, however, the return kind of `F` is defaulted to `*`.
     43     This seems rather arbitrary. We should either generalise both arguments and
     44     return kind, or default both. In case we choose to default, the more
     45     general kind can be obtained by giving a signature:
     46     {{{
     47     type family F (a :: k1) :: k2
     48     }}}
     50'''Future work:''' do more consistent kind defaulting.
    2253= [ #5682] (proper handling of infix promoted constructors) =
    2456= Kind synonyms (from type synonym promotion) =