Updating nested records

I believe the reason that Evan has given is this:

Also in the docs you find

People coming from JavaScript tend to (1) overuse records and (2) have a habit of breaking records into smaller records and to distribute them among a bunch of different files. These are both traps in Elm! (source)

so person2 would be the idomatc way to write it in elm.

Also, if you have have to update a field a lot, it might be helpful to write a utility function for it:

mapMonth : (Int -> Int) -> Date -> Date
mapMonth fun date =
   { date | month = fun date.month }

person4 : Person
person4 =
   { person1 | birthDate = mapMonth (\n -> n + 1) person1.birthDate } 
1 Like