Changes between Version 12 and Version 13 of KindFact
 Timestamp:
 Sep 12, 2011 1:54:25 PM (5 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

KindFact
v12 v13 99 99 100 100  101 == The design: implementation ==101 == Implementation == 102 102 103 103 These notes about the implementation are intended for GHC hackers, and logically form part of the GHC Commentary. … … 114 114 * '''Class constraint''': `TyConApp tc [ty1, ty2]`, where `tc` is a `TyCon` whose `classTyCon_maybe` is `Just cls`. 115 115 * '''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`. 116 117 * '''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`.118 118 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 implicitparameter `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. 120 120 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 implicitparameter `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: 122 124 {{{ 123 125 data a ~ b = Eq# (a ~# b) … … 125 127 where `Eq#` is a data constructor with a single, unboxed, zerowidth field of type `(a ~# b)`. See `TysWiredIn.eqTyCon`. 126 128 127 * The constraint solver in the type checker deals solely in terms of boxed constraints. 129 * '''Constraint tuples'' are needed for situations like 130 {{{ 131 types 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`. 128 134 129 * Constraint tup 135