Changes between Version 6 and Version 7 of Commentary/Compiler/Renamer


Ignore:
Timestamp:
Sep 11, 2007 9:27:16 AM (7 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/Renamer

    v6 v7  
    4444  -- An (OccEnv a) is a mapping from OccName to a 
    4545 
    46 data GlobalRdrElt = GRE { gre_name :: Name, gre_prov :: Provenance } 
     46data GlobalRdrElt = GRE { gre_name :: Name 
     47                        , gre_prov :: Provenance 
     48                        , gre_par :: Parent } 
    4749 
    4850data Provenance = LocalDef | Imported [ImportSpec] 
    4951 
    5052data ImportSpec = ImpSpec { is_decl :: ImpDeclSpec, is_item ::  ImpItemSpec } 
     53 
     54data Parent = NoParent | ParentIs Name 
    5155}}} 
    5256Here is how to understand these types: 
    5357 * The environment (`GlobalRdrEnv`) maps an {{{OccName}}} to a list of all entities with that occurence name that are in scope (in any way).   
     58 
    5459 * Each of these is represented by a {{{GlobalRdrElt}}}, which gives the entity's {{{Name}}} plus a specification of how it is in scope, its {{{Provenance}}}.   
     60 
    5561 * The {{{Provenance}}} has one of two forms.  Either it is in scope because it is defined in this module ({{{LocalDef}}}), or because it is imported.  In the latter case, the {{{[ImportSpec]}}} describes all the import statements that bring it into scope.  
     62 
    5663 * An {{{ImportSpec}}} has two components:  
    5764   * An {{{ImpDeclSpec}}} that describes the entire import declaration. This is shared between all entities brought into scope by a particular import declaration. 
     
    6269}}} 
    6370 the {{{ImpDeclSpec}}} would describe the {{{qualified}}} and {{{as}}} part, while the {{{ImpItemSpec}}} describes the {{{T(g)}}} part.  You can look in {{{RdrName.lhs}}} to see what an {{{ImportDeclSpec}}} and {{{ImpItemSpec}}} are like! 
     71 * The {{{Parent}}} of an entity is the {{{Name}}} under which it is grouped when the forms `T(..)` or `T(C,D)` are used in an export or import list.  In the `T(..)` form, all the things whose {{{Parent}}} is `T` are chosen.  In the `T(C,D)` form, it is required that `C` and `D` have `T` as parents.   
     72   For example,  
     73   * The `Parent` of a data constructor is its data type 
     74   * The `Parent` of a record field selector is its data type 
     75   * The `Parent` of a class operation is its class 
    6476 
    6577With all that information, we can give good error messages, especially in the case where an occurrence "f" is ambiguous (i.e. different entities, both called "f", were imported by diffferent import statements).