mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
22 lines
523 B
Text
22 lines
523 B
Text
app [main!] { pf: platform "../test-platform-effects-zig/main.roc" }
|
|
|
|
import pf.Effect
|
|
|
|
main! : {} => {}
|
|
main! = \{} ->
|
|
good = [0, 2, 4] |> List.for_each_try!(validate!)
|
|
expect good == Ok({})
|
|
|
|
bad = [6, 8, 9, 10] |> List.for_each_try!(validate!)
|
|
expect bad == Err(9)
|
|
|
|
{}
|
|
|
|
validate! : U32 => Result {} U32
|
|
validate! = \x ->
|
|
if Num.is_even(x) then
|
|
Effect.put_line!("✅ $(Num.to_str(x))")
|
|
Ok({})
|
|
else
|
|
Effect.put_line!("$(Num.to_str(x)) is not even! ABORT!")
|
|
Err(x)
|