[Haskell-cafe] sections for record settors

Neil Mitchell ndmitchell at gmail.com
Tue Sep 19 17:36:58 EDT 2006


Hi,

I agree that a function syntax for a record setter is a really good idea.

> Consider for example an cmd line parser that collects flags in
> a record.  Instead of writing:
>
>      opt "l" (NoArg  {c_loop=False})        "dont loop",
>      opt "o" (optStr {c_out=} "dir")        "output dir",
>      opt "t" (optInt {c_maxtime=} "mins")   "maximum time"

Just to show that this is a perfect example, see
http://www.cs.york.ac.uk/fp/darcs/yhc-devel/src/compiler98/Flags.hs
which has exactly the kind of problem you mention. Because there is no
setter each line is given as:

Opt ""  "lbound"    (bf $ \f x -> f{sLBound=x}) "show symbol table
after lambda lifting"

The \f x -> f bit is only there because setters are not first class
thingies. It's not quite as much additional syntax as you have in your
example, but its still not useful.

Thanks

Neil


More information about the Haskell-Cafe mailing list