src/lazy.bend

emerging-ezjson@1.2.0.0 · 10 lines · 0 definitions

1# src/lazy: `stop` returns `val` when `cond` holds, and otherwise calls rest.
2import Base
3
4# `val` when `cond`, else what rest gives: the early exit of a search
5def stop(-A: Type, cond: Bool, val: A, rest: Unit -> A) -> A:
6  match cond:
7    case True{}:
8      val
9    case False{}:
10      rest(Unit{})