Bend/tests/golden_tests/run_file/strict_monad_fn.bend
2024-06-21 20:19:43 +02:00

13 lines
387 B
Plaintext

# This will only work if we make the call to `(Result/foo a b)` lazy (by converting it to a combinator).
Result/bind = @val @nxt match val {
Result/Ok: ((undefer nxt) val.val)
Result/Err: (Result/Err val.val)
}
Result/foo x y =
with Result {
ask a = (Result/Ok x)
ask b = switch y { 0: (Result/Err a); _: (Result/Ok y-1) }
(Result/foo a b)
}
main = (Result/foo 1 2)