app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
import pf.Task
import pf.Stdout
main =
when checkInput 1 |> Task.result! is
Ok checkedValue ->
Stdout.line! "Received input $(Num.toStr checkedValue)."
Err badValue ->
# exit code 1 to indicate failure
Task.err (Exit 1 "Received bad input $(Num.toStr badValue).")
# mock Task
checkInput = \input ->
if input == 0 then
Task.ok input
else
Task.err input
❯ ./target/release/roc examples/helloWorld.roc
Received bad input 1.
roc on main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄ impure (nix-shell-env)
❯ echo $?
0
roc on main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄ impure (nix-shell-env)
❯ ./examples/helloWorld
Received bad input 1.
roc on main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄ impure (nix-shell-env)
❯ echo $?
1
Example: