flow: error model — fail/failed?/fail-reason failure values + 6 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s

Explicit (fail reason) values flow downstream as data and are inspected with
failed?/fail-reason — distinct from raised exceptions (retry/try-catch territory).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 16:35:40 +00:00
parent 65cbdb8387
commit 1731476dc6
5 changed files with 43 additions and 13 deletions

View File

@@ -19,6 +19,9 @@
;; Phase 2 combinators (flow-control-src):
;; (branch pred then else) — pred on input selects then/else node
;; (`cond` is a Scheme special form, so the combinator is named `branch`)
;; (fail reason) — make an explicit failure value (data, not an exception)
;; (failed? x) — is x a failure value?
;; (fail-reason x) — the reason carried by a failure value
(define
flow-combinators-src
@@ -26,7 +29,7 @@
(define
flow-control-src
"(define (branch pred then else)\n (lambda (input) (if (pred input) (then input) (else input))))")
"(define (branch pred then else)\n (lambda (input) (if (pred input) (then input) (else input))))\n (define (fail reason) (list (quote flow-fail) reason))\n (define (failed? x) (and (pair? x) (eq? (car x) (quote flow-fail))))\n (define (fail-reason x) (car (cdr x)))")
(define
flow-load-combinators!