Is there a proper way to do nested List.map
s? Would it be reasonable/possible to add a builtin in the form of List.innermostMap
that always runs on the elements of the innermost List. Some times when processing strings I get types like List (List U8)
. There have been other cases ase well, but it just seems inconvenient.
List.map l1 \inner -> List.map inner doInnerItem
?
I don't think it's too bad
Do empathize how it could get annoying after a while though
Yeah, That is what I am doing. Just don't like it that much.
This pipeline just is more eh in my opinion.
|> List.map (\x ->
x
|> List.reverse
|> List.map flipBracket
|> scoreClosing
)
But yeah, it does work
https://github.com/roc-lang/roc/issues/4139 would mean it wouldn't need parens
Which definitely does help a bit. Though still feels less satisfying than I would hope
I'd agree that this would come up often enough (especially in data science) to add a builtin for it. Starting the function's name with map
may also make it more discoverable so: List.mapInner
or list.mapInnermost
.
Last updated: Jul 06 2025 at 12:14 UTC