Stream: roctoberfest

Topic: 2023 day 2


view this post on Zulip Tim Wise (Oct 02 2023 at 13:35):

Just had a blast doing day 2. https://github.com/wise-tim/roctoberfest-2023/tree/master/Day2

view this post on Zulip Tim Wise (Oct 02 2023 at 13:39):

Made use of the |> List.mapTry \r -> r

view this post on Zulip Tim Wise (Oct 02 2023 at 13:42):

Very easy to follow the compiler errors, even without any IDE help. I did get briefly confused by the references to the desugared operator names in error messages eg. doing Ok a + b makes it complain about arguments to the add function.

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

Thanks for your feedback @Tim Wise, I made #5878 for the add function issue.

view this post on Zulip Elias Mulhall (Oct 03 2023 at 04:53):

https://github.com/mulias/roctoberfest/blob/main/advent_2022/day_02/main.roc
This time I used @Luke Boswell's parser library and used crash to report errors early when they didn't seem important to solving the puzzle.

view this post on Zulip Elias Mulhall (Oct 03 2023 at 04:54):

I also thought that this error message was nice, really easy to tell what was wrong

── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc ─

The branches of this when expression don't match the condition:

58│>      when (playerHand, opponentHand) is
59│           (Rock, Rock) -> Draw
60│           (Rock, Paper) -> Loss
61│           (Rock, Scissors) -> Win
62│           (Paper, Rock) -> Win
63│           (Paper, Paper) -> Draw
64│           (Paper, Scissors) -> Loss
65│           (Scissors, Rock) -> Loss
66│           (Scissors, Paper) -> Win
67│           (Scissors, Scissor) -> Draw

The when condition is a tuple of type:

    (
        Shape,
        Shape,
    )a

But the branch patterns have type:

    (
        [
            Paper,
            Rock,
            Scissors,
        ],
        [
            Paper,
            Rock,
            Scissor,
            Scissors,
        ],
    )a

The branches must be cases of the when condition's type!

view this post on Zulip Luke Boswell (Oct 03 2023 at 04:59):

Did you see the URL package? you should be able to use lukewilliamboswell/roc-parser by including the url in module header like this

app "example"
    packages {
        cli: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br",
        parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.1.0/vPU-UZbWGIXsAfcJvAnmU3t3SWlHoG_GauZpqzJiBKA.tar.br",
    }
    imports [

view this post on Zulip Luke Boswell (Oct 03 2023 at 05:02):

ooh, actually I think I may have removed whitespace... I can add that back in.

view this post on Zulip Elias Mulhall (Oct 03 2023 at 05:04):

Yea that was the issue, I just updated and copied in the missing whitespace parser


Last updated: Jul 06 2025 at 12:14 UTC