Logger counting
A custom Log handler turns three log operations into the value 3 by returning one from each operation.
- Supported engines:
env,oracle,compiled - Concepts:
effect-handlers,custom-effects,differential-testing - Refusal class: none
Canonical source: examples/logger-counting/main.bang
effect Log { log : Int -> Int }
handle
(logger.log(10)) + (logger.log(20)) + (logger.log(30))
with Log as logger {
log(msg) => 1
}Expected stdout:
3Evidence
| label | claim | sources | validating commands |
|---|---|---|---|
differential-tested | The counting and silent programs differ only in the handler clause; the env, oracle, and compiled engines produce each committed expected output byte-for-byte, and check --json plus query dump succeed for both. | examples/logger-counting/main.bang<br>examples/logger-counting/expected.txt<br>examples/logger-silent/main.bang<br>examples/logger-silent/expected.txt<br>tools/test-docfacts-logger.sh | just test-docfacts-logger |
generated | The docfact and this reference page are deterministic renderings of the canonical example files. | examples/logger-counting/main.bang<br>examples/logger-counting/expected.txt<br>docfacts/schema/example.schema.json<br>tools/docfacts_logger.py | just docs-check |