Changes between Version 48 and Version 49 of Records/OverloadedRecordFields/Implementation
- Aug 23, 2013 8:16:17 AM (20 months ago)
v48 v49 102 102 Typeclass and family instances are generated by `addLocalRecFldInsts` in `TcInstDecls`, regardless of whether or not the extension is enabled. This is called by `tcInstDecls1` to generate instances for fields from datatypes in the current group (at the same time as derived instances, from '''deriving''' clauses, are generated). The typeclass instances must be subsequently typechecked (by `tcInstDecls2`). Such instances are "private" in that they are available when typechecking the current module (in `tcg_inst_env`) but not exported to other modules (via `tcg_insts`). On the other hand, the underlying dfun ids and axioms are exported from the module as usual. 103 103 104 '''AMG''' This means that typeclass instances are not visible in GHCi, because it tracks only `tcg_insts` (via the `InteractiveContext`). What to do here? Perhaps a new field in `TcGblEnv` could record the private instances? 104 '''AMG''' This means that typeclass instances are not visible in GHCi, because it tracks only `tcg_insts` (via the `InteractiveContext`). 105 105 106 106 Moreover, `tcRnImports` calls `addImportedRecFldInsts` to add instances for overloaded record fields ''that are in scope'' from other modules. (This is different from the usual visible-everywhere story for instances.) We know which overloaded fields are in scope by looking at the `GlobalRdrEnv`. Since the dfuns and axioms are available, it is easy to turn them into appropriate `ClsInst`s and `FamInst`s. 107 107 108 '''AMG''' This is the general idea, but there are some bugs left to iron out: 109 110 * `tcIfaceGlobal` gives "not found" errors when compiling `TyCon.hs` for the stage 2 compiler. I think this might be something to do with the cycle with `Class.hs`. 111 * `addPrivateTyFamInsts` leads to fingerprinting errors, presumably because exporting an axiom without its family instance is not handled correctly. 112 * When the extension is disabled, the instances are still generated and typechecked, and they must be in scope (via `addPrivateClsInsts`/`addPrivateTyFamInsts`) while they are being typechecked. This means `tcInstDecls1` and `2` need some refactoring. 108 '''AMG''' When the extension is disabled, the instances are still generated and typechecked, and they must be in scope (via `addPrivateClsInsts`/`addPrivateTyFamInsts`) while they are being typechecked. This means `tcInstDecls1` and `2` need some refactoring. 113 109 114 110 … … 271 267 * With fundep in class, we don't need it in the instance. 272 268 * Always mangle selector names (for simplicity)? 273 * Sort out impedance mismatch with boot files, if easy or enough people care 274 * Check import/export behaviour 269 * Trouble with import/export 270 * Trouble with deriving instances in GHC.Generics (makes up un-renamed syntax using field `RdrName`s) 271 * Sort out impedance mismatch with boot files 275 272 * Minimise contents of `AvailInfo` (preferably just a list of field `OccName`s): use `newGlobalBinder` to lookup cached mangled names for selectors and pieces 276 273 277 274 * Sort out reporting of unused imports. 278 275 * Make instances available to GHCi. 276 279 277 280 278 * Consider syntactic sugar for `Upd` constraints.