Hi folks. I'm trying to test out command line parsing from the basic-cli platform, but I'm getting a thread panic. My code and output are here -- https://gist.github.com/drewolson/bef70f973c04e22e4ffe9ec44b9af135. What am I doing wrong?
I don't think its you, if I remember correctly the stuff in the arg parser module has some issues.
Ahhh yeah here is the issue.
Ah, bummer. Thanks!
i'm curious if folks think this will be fixed before Advent of Code starts. with the new website release and advent of code just around the corner, i'm sure folks will be trying out roc, and command line arg parsing seems like it would be super useful!
seems like the actual issue is https://github.com/roc-lang/roc/issues/5701
if folks think this will be fixed before Advent of Code starts
Probably not, sadly.
Ah I see, you're writing a script to fetch AoC puzzles. The website examples include an example of CLI parsing that gets around this issue, but is a bit noisier https://www.roc-lang.org/examples/CommandLineArgs/README.html
It's not even a script to fetch the puzzles, rather just accepting args from the user as to the day of the puzzle and the part to run.
so that all of my puzzles can be part of the same application. it's how i've done it for haskell and ocaml.
i suppose i could just have a program per day
or maybe this is my year of ocaml and next year is my year of roc :)
Also, you can always directly work with args <- Arg.list |> Task.await
. The bug is in the nested lambdas used for handling parsing. For AOC, naive parsing probably is enough with just directly using that list of strings.
@Brendan Hansknecht fair point. does the nested lambdas issue also become a problem for parser combinator style parsing of the input?
i feel like all i need to start aoc is some parser combinator library and some arg parsing library. oh, and sum types ;)
In case it helps anyone, I wrote this poor man's version of the arg parser while I was updating roc-pg to the latest basic-cli the other day: https://github.com/agu-z/roc-pg/blob/72f5390db26527bc3b6067f77ea570f895ff3c0b/sql-cli/src/roc-sql.roc#L191-L278
I think it can affect parser combinator style parsers.
:cry: got it, so maybe next year for me. i'm super excited about the language
or maybe this is my year of ocaml and next year is my year of roc :)
fair, they are similar languages and I love OCaml
does the nested lambdas also become a problem for parser combinator style parsing of the input?
Last month I worked through some AoC puzzles in Roc and mostly used parser combinators for parsing. You can see my code here https://github.com/mulias/roctoberfest/tree/main/advent_2022
thanks!
The one type system issue I ran into with parser combinators was a case where I needed a lazy
parser to parse recursive data. @Agus Zubiaga showed me a workaround, which is here https://github.com/mulias/roctoberfest/blob/main/advent_2022/day_07/main.roc#L158
You need to use buildPrimitiveParser
to "reset" something with the type system. Sorry I can't be more exact than that, it's definitely a hack to get around a bug.
interesting. is lazy
effectively a fixed point combinator?
ah, i see it here, thanks. https://github.com/lukewilliamboswell/roc-parser/blob/46ab6e2a8c13f69601ad516520981331c6b7ce3b/package/Core.roc#L231-L234
In general I wouldn't hesitate to use Roc for AoC if you're willing to ask for help around here. It's mostly smooth sailing, but every once in a while you run into a road block where it seems like you're doing the right thing and it's not working. Sometimes that's because you are doing the right thing and the compiler has a bug.
Last updated: Jul 26 2025 at 12:14 UTC