Stream: beginners

Topic: Is for_each implemented on `List(Str)`?


view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:52):

I’ve seen Richard mention for_each in the aoc markdown, so I’ve tried to write the following:

printbis! = |msg| msg.split_on("\n").for_each!(Stdout.line!)

And I’m getting the following error:

This for_each! method is being called on a value whose type doesn't have that method:
   ┌─ day01.roc:24:38
   │
24 │ printbis! = |msg| msg.split_on("\n").for_each!(Stdout.line!)
   │                                      ^^^^^^^^^

The value's type, which does not have a method named for_each!, is:

    List(Str)

Is this truly just a missing implementation, or is there something else happening here?

view this post on Zulip Luke Boswell (Dec 01 2025 at 10:03):

Yeah for_each doesn't exist on List

view this post on Zulip Luke Boswell (Dec 01 2025 at 10:03):

Here are all the implemented builtins
https://github.com/roc-lang/roc/blob/5e229e2060c839a195fb44266925c0c479d6309d/src/build/roc/Builtin.roc

view this post on Zulip Richard Feldman (Dec 01 2025 at 17:11):

PR for List.for_each! https://github.com/roc-lang/roc/pull/8531


Last updated: Dec 21 2025 at 12:15 UTC