Changes between Version 28 and Version 29 of TypeFunctionsTypeChecking


Ignore:
Timestamp:
Aug 22, 2006 9:34:37 PM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TypeFunctionsTypeChecking

    v28 v29  
    6262                                    TyCon     -- representation coercion 
    6363}}} 
    64 which is a generalisation of the old field `algTcClass` of the internal representation for datatypes, `TyCon.AlgTyCon`.  In contrast to the old `algTcClass` field, the new field also appears in `IfaceSyn.IfaceDecl`.  However, it does so as `Maybe (IfaceTyCon, [IfaceType])` as we still do not want to represent class parent information in interfaces and we only record the family tycon and instance types in interfaces, not the coercion.  (The latter is implicitly reconstructed upon loading an interface.) 
     64which is a generalisation of the old field `algTcClass` of the internal representation for datatypes, `TyCon.AlgTyCon`.  In contrast to the old `algTcClass` field, the new field also appears in `IfaceSyn.IfaceDecl`.  However, it does so as `Maybe (IfaceTyCon, [IfaceType])` as we still do not want to represent class parent information in interfaces and we only record the family tycon and instance types in interfaces, not the coercion.  (The latter is implicitly reconstructed upon loading an interface.)  The ''instance types'' are the type indexes at which the data constructor has been declared; e.g., given the declaration 
     65{{{ 
     66data instance Map (a, b) v = MapPair (Map a (Map b v)) 
     67}}} 
     68the instance types are `[(a, b), v]`. 
    6569 
    6670NB: The type argument variables of the representation tycon are the free variables of the instance types; i.e., the representation data type is an ordinary data type, it is neither indexed nor open.  The only give away of its special purpose is the value in `algTcParent`. 
     
    6872==== The `DataCon`s of the variants of an instance ==== 
    6973 
    70 `DataCon`s of data instances differ from ordinary `DataCon`s by a value of the form `Just typats :: Maybe [Type]` in the new field `dcInstTys`.  It gives the instance patterns at which the data constructor has been declared; e.g., given the declaration 
    71 {{{ 
    72 data instance Map (a, b) v = MapPair (Map a (Map b v)) 
    73 }}} 
    74 the instance types are `[(a, b), v]`.  Whenever the field `dcInstTys` of a `DataCon` is not `Nothing`, the field `algTcParent` of its `TyCon` must be of the form `FamilyTyCon famTyCon`, where `famTyCon` is the `TyCon` of the data family to which the instance belongs.  The exact same information goes into the interface representation `IfaceSyn.IfaceConDecl` with the new field `ifConInstTys`. 
     74`DataCon`s of data instances are not explicitly distinguished from ordinary `DataCon`s.  However, they differ by referring to a `TyCon` and a datacon wrapper that differ from their ordinary form.  More specifically, the field `algTcParent` of the `TyCon` is of the form `FamilyTyCon (famTyCon, instTys, coe)`, where `famTyCon` is the `TyCon` of the data family to which the instance belongs, `instTys` are the instance types, and `coe` is the coercion identifying representation type and family instance.  This coercion is used by the datacon wrapper whose signature uses the family type, not the representation type. 
    7575 
    7676==== The coercion identifying family instance and representation type ====