[Haskell-beginners] Copy record with mutations?
MAN
elviotoccalino at gmail.com
Wed Apr 13 23:45:10 CEST 2011
Yeah, that's basically it.
Keeping in mind that Haskell's data structures are immutable
"let stang68 = stang67"
allows to use symbol "stang68" as a new Car. Whether an actual copy is
made does not matter: even if both "stang"s point to the same structure
you're not allowed to change its values.
El mié, 13-04-2011 a las 17:27 +0200, Christopher Done escribió:
> 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 }
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list