Changes between Version 11 and Version 12 of Records/OverloadedRecordFields/Implementation


Ignore:
Timestamp:
Jul 26, 2013 11:33:25 PM (9 months ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/Implementation

    v11 v12  
    1919== The naming of cats == 
    2020 
    21 The `AvailTC Name [Name] [OccName]` constructor of `AvailInfo` represents a type and its pieces that are in scope. Record fields are now stored in a separate list (the third argument). Every field should have a corresponding selector (in the second argument). Since we have the name of the type (the first argument), we can find the selector corresponding to a field. Similar changes are required to the `IEThingWith` constructor of `IE`, which represents a thing that can be imported or exported. 
     21The `AvailTC Name [Name] [OccName]` constructor of `AvailInfo` represents a type and its pieces that are in scope. Record fields are now stored in a separate list (the third argument). Every field should have a corresponding selector (in the second argument). '''SLPJ'' Whoa!  Why should we duplicate this info.  My gut feel is that the selector should not appear in the second argument. 
     22 
     23 Since we have the name of the type (the first argument), we can find the selector corresponding to a field. Similar changes are required to the `IEThingWith` constructor of `IE`, which represents a thing that can be imported or exported. 
    2224 
    2325The `Parent` type has an extra constructor `FldParent Name OccName` that stores the parent `Name` and the field `OccName`. The `GlobalRdrElt` (`GRE`) for a field stores the selector name directly, and uses the `FldParent` constructor to store the field. Thus a field `foo` of type `T` gives rise to two entries in the `GlobalRdrEnv`: 
     
    2729foo         |->  GRE $sel_foo_T (FldParent T foo) LocalDef 
    2830}}} 
     31 
     32'''SLPJ''' I'm very dubious about the first entry.  The `GlobalRdrEnv` is exclusively about what is lexically in scope, ie strings in your source code. `$sel_foo_T` is not such a thing.  I don't think that first entry belongs in the GRE at all.  '''End of SLPJ'''. 
    2933 
    3034Note that the `OccName` used when adding a GRE to the environment now depends on the parent field: for `FldParent` it is the field rather than the selector name. 
     
    3842where the first component is the field and the second is the selector function. 
    3943 
    40 Where an AST representation type (e.g. `HsRecField` or `ConDeclField`) contained an argument of type `Located id` for a field, it now stores a `Located RdrName` for the label and `Maybe id` for the selector. The parser supplies `Nothing` for the selector; it is filled in by the renamer  (by `rnHsRecFields1` in `RnPat`, and `rnField` in `RnTypes`). Partial functions are provided to extract the `Located id`, but they will panic if called on not-yet-renamed syntax. 
     44Where an AST representation type (e.g. `HsRecField` or `ConDeclField`) contained an argument of type `Located id` for a field, it now stores a `Located RdrName` for the label and `Maybe id` for the selector. The parser supplies `Nothing` for the selector; it is filled in by the renamer  (by `rnHsRecFields1` in `RnPat`, and `rnField` in `RnTypes`). Partial functions are provided to extract the `Located id`, but they will panic if called on not-yet-renamed syntax.  '''SLPJ''' Consider using `(error "not yet filled in")` instead of a `Maybe`.  We do that quite a lot. 
    4145 
    4246