roc/examples/cli/countdown.roc
Agus Zubiaga 8dedd9f03c
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].

    app [main] {
	cli: platform "../platform/main.roc",
	json: "../json/main.roc"
    }

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] 418444862
2024-05-01 10:49:01 -03:00

19 lines
641 B
Text

app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
import pf.Stdin
import pf.Stdout
import pf.Task exposing [await, loop]
main =
_ <- await (Stdout.line "\nLet's count down from 3 together - all you have to do is press <ENTER>.")
_ <- await Stdin.line
loop 3 tick
tick = \n ->
if n == 0 then
_ <- await (Stdout.line "🎉 SURPRISE! Happy Birthday! 🎂")
Task.ok (Done {})
else
_ <- await (n |> Num.toStr |> \s -> "$(s)..." |> Stdout.line)
_ <- await Stdin.line
Task.ok (Step (n - 1))