Just had a blast doing day 2. https://github.com/wise-tim/roctoberfest-2023/tree/master/Day2
Made use of the |> List.mapTry \r -> r
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.
Thanks for your feedback @Tim Wise, I made #5878 for the add function issue.
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.
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!
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 [
ooh, actually I think I may have removed whitespace... I can add that back in.
Yea that was the issue, I just updated and copied in the missing whitespace parser
Last updated: Jul 06 2025 at 12:14 UTC