Changes between Version 3 and Version 4 of Commentary/Compiler/Renamer


Ignore:
Timestamp:
Sep 8, 2006 3:14:20 PM (8 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/Renamer

    v3 v4  
    4747 
    4848data Provenance = LocalDef | Imported [ImportSpec] 
     49 
     50data ImportSpec = ImpSpec { is_decl :: ImpDeclSpec, is_item ::  ImpItemSpec } 
    4951}}} 
    50 The environment maps an {{{OccName}}} to a list of all entities with that occurence name that are in scope (in any way).  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}}}.  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. You can look in {{{RdrName.lhs}}} to see what an {{{ImportSpec}}} is, but among other things it says whether the import is qualified-only, and whether there is an "{{{as}}}" clause on the import statement.   
     52Here is how to understand these types: 
     53 * The environment maps an {{{OccName}}} to a list of all entities with that occurence name that are in scope (in any way).   
     54 * 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}}}.   
     55 * 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.  
     56 * An {{{ImportSpec}}} has two components:  
     57   * An {{{ImpDeclSpec}}} that describes the entire import declaration. This is shared between all entities brought into scope by a particular import declaration. 
     58   * An {{{ImpItemSpec}}} that describes the import item that brought the entity into scope. 
     59 For example, given 
     60{{{ 
     61import qualified M( x, T(g) ) as Q 
     62}}} 
     63 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! 
    5164 
    5265With 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).