[Haskell-cafe] Record update fusion (or how should I call it?)

Peter Verswyvelen bugfact at gmail.com
Sun Sep 6 08:50:32 EDT 2009


I've seen a couple of package being announced that provide first class
labels, and other packages already existed for this (Grapefruit
Record, HList, Accessor, ...)

Regarding this, I have a question about the performance of multiple
composed field updates. Maybe an example.

Suppose I have a large record - say WindowDescription - which contains
a lot of fields.

Suppose I have a couple of default window description values, e.g.
defaultWindowDesc, dialogBoxDesc, etc

Using accessors it is easy to take such a default value, and "modify"
a couple of fields, like:

let myWindowDesc = set title "Haskell" . set size (640,480) . set
background Blue . set fontFamily Arial $ defaultWindowDesc

However, I guess this would make a lot of intermediate
WindowDescription copies no (whether the fields are strict or not)? So
ideally for performance, all these "updates" should be fused, maybe
running inside an ST monad?

I'm not sure if any of this is valid, but I would like to understand
more about this, so any links and hints are welcome :-)

Peter Verswyvelen


More information about the Haskell-Cafe mailing list