
14 Sep
2010
14 Sep
'10
7:17 p.m.
On Tue, Sep 14, 2010 at 1:31 PM, Jonathan Geddes
With these extensions, couldn't I write the following?
someUpdate :: MyRecord -> MyRecord someUpdate myRecord@(MyRecord{..}) = let { field1 = f field1 , field2 = g field2 , field3 = h filed3 } in myRecord{..}
No, those are recursive let bindings! If f = (1:), then field1 = [1,1,1,1...] As Conrad suggests, use: someUpdate myRecord@(MyRecord{..}) = myRecord { field1 = f field1 , field2 = f field2 , field3 = f field3 } The reason this works is that "field1" in "field1 = " is not a real scoped variable, but rather an identifier for a field in the record. It's all somewhat subtle... Luke