Changes between Version 24 and Version 25 of Records/OverloadedRecordFields/Implementation


Ignore:
Timestamp:
Aug 5, 2013 4:58:05 PM (9 months ago)
Author:
adamgundry
Comment:

type-changing update

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/Implementation

    v24 v25  
    146146 
    147147 
     148== Type-changing update: phantom arguments == 
     149 
     150Consider the datatype 
     151 
     152{{{ 
     153data T a = MkT { foo :: Int } 
     154}}} 
     155 
     156where `a` is a phantom type argument (it does not occur in the type of `foo`). The traditional update syntax can change the phantom argument, for example if `r :: T Int` then `r { foo = 3 } :: T Bool` typechecks. However, `setField` cannot do so, because this is illegal: 
     157 
     158{{{ 
     159type instance SetResult (T a) "foo" Int = T b 
     160}}} 
     161 
     162Note that the result of the type family involves an unbound variable `b`.  
     163 
     164In general, a use of `setField` can only change type variables that occur in the field type being updated, and do not occur in any of the other fields' types. 
     165 
     166 
    148167== Outstanding bugs == 
    149168 
     
    159178== To do == 
    160179 
    161 Simple update is implemented, using the design [https://github.com/adamgundry/records-prototype/blob/master/SimpleRecords.hs here]. The next step is to implement type-changing update. 
     180Test type-changing update. 
     181 
     182Sort out GADT record updates. 
    162183 
    163184Implement the syntactic sugar `r { x :: t }`.