https://github.com/mulias/roctoberfest/blob/main/advent_2022/day_01/main.roc
That was very smooth to write in roc https://github.com/isaacvando/aoc/blob/main/roctoberfest/day1.roc
@Elias Mulhall I didn't know you could import text files directly like that, that's awesome!
Yes!
General feedback:
nix-build https://github.com/roc-lang/roc/archive/main.tar.gz
before starting the puzzle. For some reason the "last edited at" timestamp on the generated binary is Dec 31st , 1969..roc-format-failed
file. Should I report those, and if so where?dbg
working at all. Is it broken right now, or is this a me thing? My biggest trouble getting day 1 working was realizing I needed Str.split "\n\n"
because I tried "\n" and had to jump through a bunch of hoops to print the intermediary state to realize that wasn't working.@Isaac Van Doren nice use of Result.withDefault 0
, I didn't think of that. I let errors propagate all the way through and it was kind of a pain.
To be a bit more specific, open tag unions feel great for error handling, but having to deal with a list of Result
s was unwieldy. I created a helper to do a List (Result a e) -> Result (List a) e
transformation, which works well enough. My initial name for the function was allOk
, but I looked up the equivalent Elm function and saw that it was called combine so I went with that. I feel like that function could be in the Roc standard library.
I think you could do |> List.mapTry \r -> r
here, but I agree that having something like Result.combine
(or join?) would be nice.
nice, I didn't think to look in List
For the timestamp, I think that is just a nix thing
Nix sets the timestamp to 1969 because it wants to build 100% the same files every time.
the formatter is failing and generating a .roc-format-failed file. Should I report those, and if so where?
Yes please :) you can do so here: https://github.com/roc-lang/roc/issues
what's the current story for parsing in general? Any libraries I can take a look at?
Luke made a parser package, I don't think he released it with a url yet but you can download the roc files to use it locally.
I can't get dbg working at all. Is it broken right now, or is this a me thing?
There are some bugs with dbg but it should work in most cases, can you file an issue?
[...] had to jump through a bunch of hoops to print the intermediary state
We've talked before about something like dbgPipeline
to print all the intermediary values in a pipeline, I'll check if we have an issue for that. It could be something nice to get done before AoC 2023.
I feel like that function could be in the Roc standard library.
I've made an issue for a Result
combine function.
I just copied that Parser from the examples, but happy to move into it's own repository and make a URL for it if that would help people?
Day 1. Cheated a little bit because I had done this before but it was back on a much older roc and roc-cli. Upgraded it really quick by removing the Process module code and fixing the return type of main. Then I refactored my part 2 solution a bit.
I noticed that the formatter does not like it if you try and put the initial state on a new line when using Lisit.walk. (Line 30).
I am curious if the state record in the part 2 solution does the mutation optimization thingy as well!
I noticed that the formatter does not like it if you try and put the initial state on a new line when using Lisit.walk. (Line 30).
The formatter does not allow a lot of freedom which I like in general, it makes all roc code look consistent and thus easier to read.
In this case I would also prefer the initial state on a separate line. It's important to easily identify where an argument ends and a new one begins.
Anton said:
the formatter is failing and generating a .roc-format-failed file. Should I report those, and if so where?
Yes please :) you can do so here: https://github.com/roc-lang/roc/issues
https://github.com/roc-lang/roc/issues/5880
Last updated: Jul 06 2025 at 12:14 UTC