src/lazy.bend
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{})