Jonathan Geddes schrieb: > I know that record updates is a topic that has become a bit of a dead > horse, but here I go anyway: > > I find that most of the record updates I read and write take the form > >> someUpdate :: MyRecord -> MyRecord >> someUpdate myRecord = myRecord >> { field1 = f $ field1 myRecord >> , field2 = g $ field2 myRecord >> , field3 = h $ filed3 myRecord >> } > > I find myself wishing I could write something more like > >> someUpdate :: MyRecord -> MyRecord >> someUpdate myRecord = myRecord >> { field1 => f >> , field2 => g >> , field3 => h >> }
data-accessor and similar packages may become your friends. data-accessor allows you to write: someUpdate = (field1 ^: f) . (field2 ^: g) . (field3 ^: h) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe