Stream: contributing

Topic: Implement `List.update` and `List.updater`


view this post on Zulip Lunarmagpie (Dec 25 2022 at 03:28):

Hi, im interested in implementing the List.update and List.updater builtins but I have a few questions.

view this post on Zulip Brendan Hansknecht (Dec 25 2022 at 03:46):

I have some guesses:

Same pr:
probably fine. If they end up being complex, better separate

Int vs Nat: yeah, should be Nat

Function signature: i have stared at it for a bit, and my gut feeling is that we probably want to change the signature. That said, i think i get it now. it takes a list and an index. It returns the element at that index. It also returns a function that when given a element creates a new list that is identical to the original list, but with the element at index updated to the new element passed in.

So kinda like some sort of delayed replace function.

I could be wrong. Really confused about the use case/goal here.

view this post on Zulip Lunarmagpie (Dec 25 2022 at 03:57):

That makes sense for List.updater to me. Personally not sure of the use case either tbh.

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:02):

where are these mentioned? :sweat_smile:

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:02):

I don't actually recognize them!

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:02):

oh I see - in https://github.com/roc-lang/roc/issues/664

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:04):

hm, I think we should take those off that list until someone has a use case for them - thoughts?

view this post on Zulip Lunarmagpie (Dec 25 2022 at 04:15):

List.update i think can be decently useful in roc since otherwise you would have to handle a Result from List.get. I think it can be useful in a pinch for something like the AOC problem this year with the monkeys where you needed to modify an item in a set, tho i don't do that very regularly.
List.updater feels bloated for a standard lib to me.

I don't think I would miss either of these functions if they weren't builtin.

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:17):

yeah let's just hold off :big_smile:

view this post on Zulip Richard Feldman (Dec 25 2022 at 04:17):

are there any others you're interested in tackling as a first contribution?

view this post on Zulip Lunarmagpie (Dec 25 2022 at 04:20):

I might take a stab at the result mapping ones listed in #664 cause they look easy, someone just has to do them and write docs and tests.

view this post on Zulip Lunarmagpie (Dec 25 2022 at 04:21):

Nobody wants to write docs and tests :sob:


Last updated: Jul 06 2025 at 12:14 UTC