Changes between Version 3 and Version 4 of TypeFunctions/ClassFamilies


Ignore:
Timestamp:
May 16, 2007 2:01:42 AM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TypeFunctions/ClassFamilies

    v3 v4  
    5252class instance ctxt => C t1 .. tn where { sigs }
    5353}}}
     54where I'd propose to not allow functional dependencies to keep matters simpler.
     55
    5456Class instances of class-family instances take the normal form.  The only additional constraint is that the class parameters are type instances of the class-family instance types.  That is, if we have
    5557{{{
     
    6466=== Type checking ===
    6567
    66 Like with data families, there is little impact on type checking.  Methods of class-family instances have signatures whole class constraints are not just variables.  For example,
     68Like with data families, there is little impact on type checking.  Methods of class-family instances have signatures whose class constraints are not just variables.  For example,
    6769{{{
    6870class instance C Int a where
     
    7375foo :: C Int a => a -> a
    7476}}}
    75 Otherwise, superclasses and class instance introduce the usual given constraints.
     77Otherwise, superclasses and class instance introduce the usual given constraints. 
     78
     79However, to implement superclass constraints, we need to have a `ClassInstEnv` (similar to the `InstEnv` and `FamInstEnv` right now).  For a vanilla class, if we have `C t1 .. tn` in the constraint pool, we just can add all superclasses of `C` at the appropriate instance types.  However, if `C` is a class family, we need to check whether there is a class-family instance `C r1 .. rn` and a substitution `theta`, such that `theta (C r1 .. rn) == C t1 .. tn`, then we can add the superclasses of `C r1 .. rn` at the instance types suggested by `theta`.  This check for a class-family instance requires a function `lookupClassInstEnv` (similar to the current `lookupInstEnv` and `loookupFamInstEnv`).
     80
     81Finally, we need to exclude overlap of class-family instances in the same way as for data-family instances.
    7682
    7783=== Desugaring ===
     
    109115$dCs1sm dicts = $WR42C <superdict> methods
    110116}}}
    111 Moreover, we will have a `InstEnv.Instance` representation of the instance where `is_class` is the name of the class family and `is_tys` is `s1` to `sn`.  This is as constraint simplification does not know anything about the class-family instances.
     117Moreover, we will have a `InstEnv.Instance` representation of the instance where `is_class` is the name of the class family and `is_tys` is `s1` to `sn`.  This is as lookup in an `InstEnv.InstEnv` does not need to make a distinction between vanilla classes and class-family instances.
    112118
    113119=== Related work ===