Changes between Version 20 and Version 21 of Records/OverloadedRecordFields/Implementation


Ignore:
Timestamp:
Aug 1, 2013 4:10:57 PM (2 years ago)
Author:
adamgundry
Comment:

GADT record updates

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/Implementation

    v20 v21  
    1515{{{
    1616$sel_x_T :: T -> Int       -- record selector (used to be called `x`)
    17 $sel_x_T (T x) = x
     17$sel_x_T (MkT x) = x
    1818
    1919$dfHasTx :: Has T "x"      -- corresponds to the Has instance decl
     
    119119
    120120
     121== GADT record updates ==
     122
     123Annoyingly, the generated code for `setField` doesn't typecheck for GADTs, because of #2595. At the moment, it generates
     124
     125{{{
     126setField _ s e = s { x = e }
     127}}}
     128
     129for updating the field `x`, and this record update is rejected by the typechecker even though it is perfectly sensible. The alternative is to generate the rather long-winded explicit update
     130
     131{{{
     132setField _ (MkT1 f1 ... fi-1 _ fi+1 ... fn) e = MkT1 f1 ... fi-1 e fi+1 ... fn
     133...
     134setField _ (MkTm ...)                       e = MkTm ...
     135}}}
     136
     137I wonder if it would be easier to fix #2595.
     138
    121139
    122140== Outstanding bugs ==