[Haskell-cafe] Record updates
Malcolm Wallace
malcolm.wallace at cs.york.ac.uk
Sun Mar 29 08:41:10 EDT 2009
> Now suppose that foo3 :: [Int], and I want to prepend 5 to it. I end
> up having to write something like
>
> let v1 = v0 {foo3 = 5 : (foo3 v0)}
There used to be a feature in pre-Haskell'98 called "named field
puns", which allows to use a shorter form of field access. Your
example would come out as
f v0{foo3} =
let v1 = v0 {foo3 = 5: foo3} in ...
Have a look in the Haskell-1.4 Language Report to see how it works.
The behaviour is still supported as an extension by Hugs (-98), nhc98
(-puns), and ghc (-XNamedFieldPuns).
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list