# Updating nested records

**URL:** <https://discourse.elm-lang.org/t/updating-nested-records/9719>\
**Category:** Learn\
**Created:** [March 18, 2024, 10:46pm UTC](https://discourse.elm-lang.org/t/updating-nested-records/9719 "2024-03-18T22:46:26Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Lucas\_Payr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/lucas_payr/32/4993_2.png) [@Lucas\_Payr](https://discourse.elm-lang.org/u/Lucas_Payr)\
**Post date:** [March 19, 2024, 6:12am UTC](https://discourse.elm-lang.org/t/updating-nested-records/9719/3 "2024-03-19T06:12:51Z")

</div>

I believe the reason that Evan has given is this:

> [@Proposal: record setters](https://discourse.elm-lang.org/t/proposal-record-setters/5920/6):
>
> the current design encourages the use of named top-level functions

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)](https://elm-lang.org/docs/records)

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:

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

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

```

---

_[View the full topic](https://discourse.elm-lang.org/t/updating-nested-records/9719)._
