Malcolm Wallace wrote:
perhaps cond f field = if cond then f field else field

    foo { bar = perhaps cond0 f (bar foo)
        , wib = perhaps cond1 g (wib foo) }

I tend to write functions:


upd_bar f x = x { bar = f (bar x) }
upd_wib f x = x { wib = f (wib x) }

in order to avoid mentioning the field names twice later on. Does it cost much if I sometimes supply "id" as update argument?

It would be nice if such update functions could be generated or if there were another special update syntax. Does it exist in other languages?

Cheers Christian

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to