[Haskell-beginners] Copy record with mutations?

Christopher Done chrisdone at googlemail.com
Wed Apr 13 17:27:08 CEST 2011


On 13 April 2011 17:22, Andrew n marshall <andrew.n.marshall at gmail.com>wrote:

>
> Is there a syntax or function to copy a record, but with select fields
> populated with new values?
>
> For example, extending LYAH's Car
>
> let stang67 = Car {company="Ford", model="Mustang", year=1967}
> let stang68 = stang67 `mutate` Car {year=1968}
>
>
let stang67 = Car {company="Ford", model="Mustang", year=1967}
let stang68 = stang67 { year = 1968 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110413/c26c932b/attachment-0001.htm>


More information about the Beginners mailing list