main : Program
main = Program.noArgs (Task.attempt mainTask \result ->
exitCode = when result is
Ok {} -> 0
Err _ -> 1
Task.succeed {} |> Program.exit exitCode
)
mainTask =
Task.await
(File.readUtf8 (Path.fromStr "../../1"))
\contents ->
x = if contents == "asdf" then 1 else 2
Num.toStr x
|> Stdout.line
I'm getting this error, but {}
is a pattern, no?
I was partway through parsing a when expression, but I got stuck here:
9│ Ok {} -> 0
^
I was expecting to see a pattern next
I think the issue is tabbing. I am not exactly sure how this part of the parser works, what happens if you write:
exitCode =
when result is
Ok {} -> 0
Err _ -> 1
It works! Thank you!
Michał Łępicki has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC