I don't know if this is the correct place to suggest this, because it is about @Luke Boswell's roc-parser package. If you want me to do it in a github issue on that repo, I will do it there.
I am a big fan of the package whenever solving programming puzzles (mainly advent of code). However, since the new record builder syntax was introduced, I found myself using the map2 function exclusively over the keep and skip functions, since I find it more intuitive and removes the need for a deeply curried function. Do others think the same or is it just me?
If it is not just me I suggest changing the examples to use record builder syntax instead of keep and skip, and maybe rename map2 to combine or something like that.
That would be a great example to have! Consider either apply or sequence, any name that implies you're grouping either 2 or N things in a row
@Kilian Vounckx could you please share an example or two? I haven't seen the new record builders used in this way, and I think that sounds really cool.
A converted example from the repo would be
singleNumber =
{ Core.map2 <-
n: String.digits,
_: String.string "\n",
}
|> Core.map .n
Now here, because there is only one used field, we need an extra call to Core.map to extract it, so maybe it isn't ideal. However in the following parser for advent of code it definitely helps:
{ Core.map2 <-
min: String.digits,
_: String.codeunit '-',
max: String.digits,
_: String.codeunit ' ',
char: String.codeunitSatisfies isAlpha,
_: String.string ": ",
password: Core.oneOrMore (String.codeunitSatisfies isAlpha)
}
Normally you would need a nested curried function here \min -> \max -> \char -> \password -> { min, max, char, password } with keep and skip. With record builders this isn't needed anymore
love it! :heart_eyes:
while we're at it, could we rename Core? It doesn't really fit with the naming conventions of the rest of the ecosystem :sweat_smile:
I always import parser.Core as Parser :big_smile:
Last updated: Jun 16 2026 at 16:19 UTC