Changes between Version 31 and Version 32 of Records/OverloadedRecordFields/Implementation


Ignore:
Timestamp:
Aug 8, 2013 1:25:36 PM (22 months ago)
Author:
adamgundry
Comment:

data family trouble

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/Implementation

    v31 v32  
    170170 
    171171 
     172== Data families == 
     173 
     174Consider the following: 
     175 
     176{{{ 
     177data family F (a :: *) :: * 
     178data instance F Int  = MkF1 { foo :: Int } 
     179data instance F Bool = MkF2 { foo :: Bool } 
     180}}} 
     181 
     182This is perfectly sensible, and should give rise to two *different* record selectors `foo`, and corresponding `Has` instances: 
     183 
     184{{{ 
     185instance t ~ Int => Has (F Int) "foo" t 
     186instance t ~ Bool => Has (F Bool) "foo" t 
     187}}} 
     188 
     189However, what can we call the record selectors? They can't both be `$sel_foo_F`! Ideally we would use the name of the representation tycon, rather than the family tycon, but that isn't introduced until the typechecker (`tcDataFamInstDecl` in `TcInstDcls`), and we need to create the selector in the renamer (`getLocalNonValBinders` in `RnNames`). We can't just pick an arbitrary unique name, because we need to look up the selector to associate it with its data constructor (`extendRecordFieldEnv` in `RnSource`). 
     190 
     191 
    172192== Outstanding bugs == 
    173193 
     
    180200* ghci/prog002 prog003 scripts/ghci029 ghci036 ghci037 (scope issues in GHCi) 
    181201* typechecker/should_fail/tcfail102 (changed error message)  
    182 * driver/T4437 (should OverloadedRecordFields be a GHC-only extension, or should Cabal know about it?) 
     202* driver/T4437 (should `OverloadedRecordFields` be a GHC-only extension, or should Cabal know about it?) 
    183203 
    184204 
    185205== To do == 
    186206 
    187 * Test data families with fields. 
    188207* Sort out GADT record updates. 
     208* Sort out data families with duplicated fields. 
    189209* Fix the interaction between fields and qualified names: a qualified name can be used for unambiguous identification of fields (e.g. in updates) but should not be used as an overloaded variable. 
    190210* Improve error messages from typechecker: