Std.Control
Classic monadic effects: Reader (ambient environment) and Writer (ambient append-only log), expressed as algebraic effects.
Effects
Reader
effect Reader r {
fun ask : Unit -> r
}Reader effect: an ambient read-only environment of type r.
Use ask! to read the environment from anywhere in the call tree;
install with run_reader env (fun () -> ...).
Tell
effect Tell w {
fun tell : w -> Unit
}Writer effect: an ambient append-only sink of type w. Use tell!
to push a value from anywhere in the call tree; install with
run_writer (fun () -> ...) to recover the pair (result, log).
Functions
run_reader
fun run_reader : (env: r) -> (f: Unit -> a needs {Reader r}) -> aRun a Reader-effecting computation against the given environment.
run_writer
fun run_writer : (f: Unit -> a needs {Tell w}) -> (a, List w)Run a Tell-effecting computation, returning its value paired with everything told, in chronological order.