Generating "setMember" functions for record structures
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Tue Sep 23 15:35:51 EDT 2003
Peter Simons <simons at cryp.to> writes:
> > setFoo :: State -> [Int] -> State
> > setFoo st x = State { foo = x
> > , bar = bar st
> > }
There is an easier way to do this, using the record update syntax
rather than record construction syntax. e.g.
setFoo st x = st { foo = x }
All the unmentioned fields retain their previous values from the
'st' structure.
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list