Stream: roctoberfest

Topic: 2023 day 1


view this post on Zulip Elias Mulhall (Oct 02 2023 at 01:35):

https://github.com/mulias/roctoberfest/blob/main/advent_2022/day_01/main.roc

view this post on Zulip Isaac Van Doren (Oct 02 2023 at 01:38):

That was very smooth to write in roc https://github.com/isaacvando/aoc/blob/main/roctoberfest/day1.roc

view this post on Zulip Isaac Van Doren (Oct 02 2023 at 01:39):

@Elias Mulhall I didn't know you could import text files directly like that, that's awesome!

view this post on Zulip Elias Mulhall (Oct 02 2023 at 01:41):

Yes!

view this post on Zulip Elias Mulhall (Oct 02 2023 at 01:47):

General feedback:

view this post on Zulip Elias Mulhall (Oct 02 2023 at 01:48):

@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.

view this post on Zulip Elias Mulhall (Oct 02 2023 at 01:54):

To be a bit more specific, open tag unions feel great for error handling, but having to deal with a list of Results 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.

view this post on Zulip Agus Zubiaga (Oct 02 2023 at 02:25):

I think you could do |> List.mapTry \r -> r here, but I agree that having something like Result.combine (or join?) would be nice.

view this post on Zulip Elias Mulhall (Oct 02 2023 at 02:34):

nice, I didn't think to look in List

view this post on Zulip Brendan Hansknecht (Oct 02 2023 at 02:39):

For the timestamp, I think that is just a nix thing

view this post on Zulip Anton (Oct 02 2023 at 08:33):

Nix sets the timestamp to 1969 because it wants to build 100% the same files every time.

view this post on Zulip Anton (Oct 02 2023 at 08:41):

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

view this post on Zulip Anton (Oct 02 2023 at 09:06):

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.

view this post on Zulip Anton (Oct 02 2023 at 09:12):

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?

view this post on Zulip Anton (Oct 02 2023 at 09:17):

[...] 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.

view this post on Zulip Anton (Oct 02 2023 at 09:26):

I feel like that function could be in the Roc standard library.

I've made an issue for a Result combine function.

view this post on Zulip Luke Boswell (Oct 02 2023 at 10:00):

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?

view this post on Zulip Erik (Oct 02 2023 at 13:36):

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!

view this post on Zulip Anton (Oct 02 2023 at 15:02):

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.

view this post on Zulip Elias Mulhall (Oct 02 2023 at 23:33):

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