Changes between Version 30 and Version 31 of Records/NameSpacing


Ignore:
Timestamp:
Jan 12, 2012 10:10:36 PM (2 years ago)
Author:
strake888
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Records/NameSpacing

    v30 v31  
    116116The function update syntax is a new addition to Haskell that we do not need to immediately implement. 
    117117 
    118 === Alternative update syntax: using tuple selectors === 
    119  
     118=== Alternative update syntax: let syntax === 
     119 
     120As an example, we define a record type and value: 
     121{{{ 
     122data R = R { ..., w :: W, x :: X, y :: Y, z :: Z, a :: A, ... } 
     123 
     124r = R { ..., x = undefined, y = undefined, z = undefined, ... } 
     125}}} 
     126 
     127Then to change x, y, z, we write 
    120128{{{ 
    121129let { r.x = x'; r.y = y'; r.z = z'; } in r 
    122130}}} 
    123131 
    124 If we allow tuples of selectors: 
     132For brevity, if we allow tuples of selectors: 
    125133{{{ 
    126134r.(x, y, z) = (r.x, r.y, r.z) 
     
    130138{{{ 
    131139let r.(x, y, z) = (x', y', z') in r    
    132 }}}              
     140}}} 
     141 
     142Thus the language would be simpler (little/no new syntax to define), 
     143and it would keep to the principle of Least Surprise (little/no new 
     144syntax to learn). 
    133145 
    134146== Interaction with Typeclasses ==