Changes between Version 6 and Version 7 of TypeFunctionsRenaming


Ignore:
Timestamp:
Oct 20, 2006 9:07:10 PM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TypeFunctionsRenaming

    v6 v7  
    3131=== Name parents & importing and exporting === 
    3232 
    33 GHC, in `RnNames`, derives its knowledge of which names may appear in parenthesis after a type or class name in an import or export list by querying the name parent relation (i.e., invoking `Name.nameParent_maybe`.  Hence, it is crucial that all the data constructors defined in instances of a family get the family name, not the name of the representation tycon, as their name parent.  We go to some effort in `RnNames.newTopSrcBinder` to achieve this when renaming source.  We also need an extra measure, even if of much smaller scale, when sucking declarations from interface files in `LoadIface.loadDecl`.  Here we make the family the name parent for all implicit things of the declaration. 
     33GHC, in `RnNames`, derives its knowledge of which names may appear in parenthesis after a type or class name in an import or export list by querying the name parent relation, as encoded in `RdrName.gre_par` of `RdrName.GlobalRdrElt`.  Hence, it is crucial that all the data constructors defined in instances of a family get the family name, not the name of the representation tycon, as their name parent.  We go to some effort in `RnNames.getLocalDeclBinders` to achieve this when renaming source.  We also , when sucking declarations from interface files in `LoadIface.loadDecl`, make the family the name parent for all implicit things of the declaration. 
     34 
     35An extra complication with the name parent relation that arises due to associated types is that the name parent relation can have a depth of two (not just one as in H98).  Here is an example: 
     36{{{ 
     37class GMapKey a where 
     38  data GMap a :: * -> * 
     39instance GMapKey Int where 
     40  data GMap Int v = GMapInt ... 
     41}}} 
     42The data constructor GMapInt's parent is GMap whose parent in turn is the class GMapKey; ie, GMapKey is GMapInt's grand parent.  In H98, data types have no parents (which is in some places in the code represented by making them their own parent). 
     43 
     44We address this in `RnNames.filterImports` by extending the occurences environment `occ_env` by an extra, but optional parent component.  In the case of associated types, this new component gives the class in which the associated types has been declared. 
     45 
     46Finally, to ensure that family instances put into interface files and associated type declarations are not duplicated on the top-level of an interface file, we need to take care in `TyCon.isImplicitTyCon` to guarantee that (a) associated family declarations are implicit and (b) family instance representation tycons are not.