Changes between Version 12 and Version 13 of KindFact


Ignore:
Timestamp:
Sep 12, 2011 1:54:25 PM (3 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • KindFact

    v12 v13  
    9999 
    100100-------------------------- 
    101 == The design: implementation == 
     101== Implementation == 
    102102 
    103103These notes about the implementation are intended for GHC hackers, and logically form part of the GHC Commentary. 
     
    114114   * '''Class constraint''': `TyConApp tc [ty1, ty2]`, where `tc` is a `TyCon` whose `classTyCon_maybe` is `Just cls`. 
    115115   * '''Implicit parameter''': `TyConApp tc [ty1]`, where `tc` is a `TyCon` whose `tyConIP_maybe` is `Just ip`. 
     116   * '''Tuple constraint''': `TyConApp tup_tc [ty1, ..., tyn]`, where `tup_tc` is a constraint tuple `TyCon`.   
    116117   * '''Constraint variable''': `TyVarTy tv` where `tv` has kind `Constraint`. 
    117    * '''Tuple constraint''': `TyConApp tup_tc [ty1, ..., tyn]`, where `tup_tc` is a constraint tuple `TyCon`.   
    118118 
    119  * Implicit parameters have a type written `?x::Int`, say.  Concretely, this is represented as `TyConApp ?x [intTy]`, where `intTy` is the representation of the type for `Int`, and `?x` is a `TyCon` of kind `(* -> *)`.  There is an infinite family of such implicit-parameter `TyCon`s; see data constructor `IPTyCon` in data type `TyConParent` in `TyCon`. 
     119 * Constraint types (ie types with kind `Constraint`) are always boxed. The constraint solver in the type checker deals solely in terms of boxed constraints. 
    120120 
    121  * Constraint types (ie types with kind `Constraint`) are always boxed, including equality constraints.  So `(a ~ b)` is a ''boxed'' value.   We also have a primtive type of ''unboxed'' equality constraints, written `(a ~# b)`.  Roughly the former is declared thus: 
     121 * '''Implicit parameters''' have a type written `?x::Int`, say.  Concretely, this is represented as `TyConApp ?x [intTy]`, where `intTy` is the representation of the type for `Int`, and `?x` is a `TyCon` of kind `(* -> *)`.  There is an infinite family of such implicit-parameter `TyCon`s; see data constructor `IPTyCon` in data type `TyConParent` in `TyCon`. 
     122 
     123 * '''Equality constraints'''.  Constraint types are always boxed, including equality constraints.  So `(a ~ b)` is a ''boxed'' value.   We also have a primtive type of ''unboxed'' equality constraints, written `(a ~# b)`.  Roughly the former is declared thus: 
    122124{{{ 
    123125data a ~ b = Eq# (a ~# b) 
     
    125127 where `Eq#` is a data constructor with a single, unboxed, zero-width field of type `(a ~# b)`.  See `TysWiredIn.eqTyCon`. 
    126128 
    127  * The constraint solver in the type checker deals solely in terms of boxed constraints. 
     129  * '''Constraint tuples'' are needed for situations like 
     130{{{ 
     131types X a = (Show a, Ix a) 
     132}}} 
     133  Although we use standard tuple syntax, internally we use a separate infinite family of tuple `TyCon`s, just as we separate the boxed and unboxed type families.  See `BasicTypes.TupleSort`. 
    128134 
    129   * Constraint tup 
     135