Changes between Version 51 and Version 52 of Records/OverloadedRecordFields/Implementation


Ignore:
Timestamp:
Aug 26, 2013 10:12:19 AM (8 months ago)
Author:
adamgundry
Comment:

names

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/Implementation

    v51 v52  
    3030 
    3131== The naming of cats == 
     32 
     33=== `FieldLabel` === 
    3234 
    3335A field is represented by the following datatype, parameterised by the representation of names: 
     
    4850}}} 
    4951 
    50 Every field has a label (`OccName`), selector, and names for the typeclass and family instances (currently stored together in the `FldInsts` record, but this could change). 
    51  
    52 The `AvailTC Name [Name] [FieldLabel]` 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). The `IEThingWith name [name] [OccName]` constructor of `IE`, which represents a thing that can be imported or exported, stores only the `OccName`s. 
    53  
    54 The `Parent` type has an extra constructor `FldParent Name OccName (Maybe (FldInsts Name))` that stores the parent `Name`, the field `OccName`, and the names of the instances if they are defined. The `GlobalRdrElt` (`GRE`) for a field stores the selector name directly, and uses the `FldParent` constructor to store the field. Thus a field `x` of type `T` gives rise this entry in the `GlobalRdrEnv`: 
    55  
    56 {{{ 
    57 x |->  GRE $sel_x_T (FldParent T x (FldInsts $dfHasTx $dfUpdTx TFCo:R:GetResultTx TFCo:R:SetResultTx)) LocalDef 
    58 }}} 
    59  
    60 Note that the `OccName` used when adding a GRE to the environment (`greOccName`) now depends on the parent field: for `FldParent` it is the field label rather than the selector name. 
    61  
    62 The `dcFields` field of `DataCon` stores a list of `FieldLabel`, whereas the `ifConFields` field of `IfaceConDecl` stores a list of `FieldLbl OccName`. 
     52Every field has a label (`OccName`), selector, and names for the dfuns and axioms (currently stored together in the `FldInsts` record, but this could change). The `dcFields` field of `DataCon` stores a list of `FieldLabel`, whereas the `ifConFields` field of `IfaceConDecl` stores a list of `FieldLbl OccName`. The motivation for storing the names of the pieces is to avoid dragging `extendInteractiveContext` into the monad with `gresFromAvails`. 
     53 
     54 
     55=== `AvailInfo` and `IE` === 
     56 
     57The new definition of `AvailInfo` is: 
     58 
     59{{{ 
     60data AvailInfo      = Avail Name | AvailTC Name [Name] AvailFields 
     61data AvailFlds name = NonOverloaded [name] | Overloaded [OccName] 
     62type AvailFields    = AvailFlds Name 
     63}}} 
     64 
     65The `AvailTC` constructor represents a type and its pieces that are in scope. Record fields are now stored in a separate list (the third argument). If the fields are not overloaded, we store the selector names, whereas if they are overloaded, we store only the labels. 
     66 
     67The `IEThingWith name [name] [OccName]` constructor of `IE`, which represents a thing that can be imported or exported, stores only the `OccName`s. 
     68 
     69 
     70=== `Parent` and `GlobalRdrElt` === 
     71 
     72The `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 `x` of type `T` gives rise this entry in the `GlobalRdrEnv`: 
     73 
     74{{{ 
     75x |->  GRE $sel_x_T (FldParent T x) LocalDef 
     76}}} 
     77 
     78Note that the `OccName` used when adding a GRE to the environment (`greOccName`) now depends on the parent field: for `FldParent` it is the field label rather than the selector name. Since `AvailInfo` does not store selectors for overloaded fields, `gresFromAvails` is now defined in the `TcRnIf` monad so that it can call `lookupOrig` to find the selectors. 
    6379 
    6480 
     
    273289 
    274290* With fundep in class, we don't need it in the instance. 
    275 * Minimise contents of `AvailInfo` (to a list of `AvailFields Name`, where `data AvailFields name = NonOverloaded [name] | Overloaded [OccName]`). Use `lookupOrig` to lookup cached mangled names for selectors and pieces (get a `Module` from the `TyCon` `Name`). 
    276 * When there is only one thing in scope, don't do make it polymorphic (but document trade-offs). 
     291* When there is only one thing in scope, don't do make it polymorphic (but document trade-offs). But maybe it should still support lenses? 
    277292* Forbid ambiguous qualified overloaded fields. 
    278293* Add `HsVarOut RdrName id` instead of `HsSingleRecFld` (or perhaps rename `HsVar` to `HsVarIn`); also useful to recall how the user referred to something. 
    279 * Could resolve Has constraints in the solver, like newtype coercions and SingI, rather than the instance malarkey. 
     294* Resolve Has constraints in the solver, like newtype coercions and SingI, rather than the instance scoping malarkey. 
    280295 
    281296* Sort out reporting of unused imports. 
    282297* Make instances available to GHCi. 
    283 * Haddock prints selector names in index and LaTeX exports list 
     298* Haddock prints selector names in index and LaTeX exports list. 
     299* What's going on with deprecations and fixity decls? 
    284300 
    285301* Consider syntactic sugar for `Upd` constraints.