roc/examples/cli/effects.roc
2024-11-07 18:54:19 -03:00

27 lines
584 B
Text

app [main!] { pf: platform "effects-platform/main.roc" }
import pf.Effect
main! : {} => {}
main! = \{} ->
["Welcome!", "What's your name?"]
|> forEach! Effect.putLine!
line = Effect.getLine! {}
if line == "secret" then
Effect.putLine! "You found the secret"
Effect.putLine! "Congratulations!"
else
{}
Effect.putLine! "You entered: $(line)"
Effect.putLine! "It is known"
forEach! : List a, (a => {}) => {}
forEach! = \l, f! ->
when l is
[] -> {}
[x, .. as xs] ->
f! x
forEach! xs f!