Changes between Version 25 and Version 26 of GhcKinds


Ignore:
Timestamp:
Dec 20, 2011 1:47:06 PM (4 years ago)
Author:
dreixel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GhcKinds

    v25 v26  
    44 
    55This 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. 
     6 
    67 
    78= Explicit kind variables = 
     
    1819Since the core language has all the support for kind variables, this shouldn't be too hard. 
    1920 
     21 
    2022= Kind defaulting in type families = 
    2123 
     24At the moment, when you define a type family without `-XPolyKinds` like this: 
     25{{{ 
     26type family F a 
     27}}} 
     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 
     31types. 
     32 
     33When you turn `-XPolyKinds` on, however, we currently give `F` the kind 
     34`forall (k :: BOX). k -> *`. This is unsatisfactory for two reasons: 
     35 
     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]. 
     41     
     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     }}} 
     49 
     50'''Future work:''' do more consistent kind defaulting. 
     51  
     52 
    2253= [http://hackage.haskell.org/trac/ghc/ticket/5682 #5682] (proper handling of infix promoted constructors) = 
     54 
    2355 
    2456= Kind synonyms (from type synonym promotion) =