Ticket #5938 (closed bug: fixed)

Opened 15 months ago

Last modified 14 months ago

Kind variables not allowed in type family instance declarations

Reported by: goldfire Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.5
Keywords: PolyKinds Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Difficulty: Unknown
Test Case: polykinds/T5938 Blocked By:
Blocking: Related Tickets:

Description

I am trying to create a kind-indexed type family, but I cannot use kind variables in my kind annotations:

{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}

type family KindFam a
type instance KindFam (a :: *) = Int
type instance KindFam (a :: Bool) = Bool
type instance KindFam (a :: Maybe k) = Char -- doesn't work

Change History

Changed 15 months ago by goldfire

  • keywords PolyKinds added

Changed 14 months ago by simonpj@…

commit c5554f8290f5acc5f52ab1ea6488a75d0ffa34e5

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Fri Apr 13 21:40:56 2012 +0100

    Allow kind-variable binders in type signatures
    
    This is the last major addition to the kind-polymorphism story,
    by allowing (Trac #5938)
    
     type family F a   -- F :: forall k. k -> *
     data T a          -- T :: forall k. k -> *
     type instance F (T (a :: Maybe k)) = Char
    
    The new thing is the explicit 'k' in the type signature on 'a',
    which itself is inside a type pattern for F.
    
    Main changes are:
    
    * HsTypes.HsBSig now has a *pair* (kvs, tvs) of binders,
      the kind variables and the type variables
    
    * extractHsTyRdrTyVars returns a pair (kvs, tvs)
      and the function itself has moved from RdrHsSyn to RnTypes
    
    * Quite a bit of fiddling with
         TcHsType.tcHsPatSigType and tcPatSig
      which have become a bit simpler.  I'm still not satisfied
      though.  There's some consequential fiddling in TcRules too.
    
    * Removed the unused HsUtils.collectSigTysFromPats
    
    There's a consequential wibble to Haddock too

 compiler/deSugar/DsMeta.hs          |    8 ++-
 compiler/hsSyn/HsTypes.lhs          |   11 +++-
 compiler/hsSyn/HsUtils.lhs          |   34 +---------
 compiler/parser/Parser.y.pp         |    6 +-
 compiler/parser/ParserCore.y        |    2 +-
 compiler/parser/RdrHsSyn.lhs        |   64 -----------------
 compiler/rename/RnSource.lhs        |   12 ++--
 compiler/rename/RnTypes.lhs         |  133 +++++++++++++++++++++++++++++++---
 compiler/typecheck/TcHsType.lhs     |  111 ++++++++++++++++++------------
 compiler/typecheck/TcMType.lhs      |   37 +++-------
 compiler/typecheck/TcRules.lhs      |   48 ++++++-------
 compiler/typecheck/TcTyClsDecls.lhs |   40 +++++++++--
 compiler/typecheck/TcType.lhs       |    3 +
 13 files changed, 283 insertions(+), 226 deletions(-)

Changed 14 months ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed
  • testcase set to polykinds/T5938
Note: See TracTickets for help on using tickets.