flow: Phase 1 declarative DAG — sequence/parallel/defflow combinators + 18 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s
Flow combinators as a Scheme prelude loaded onto scheme-standard-env; a flow is a Scheme procedure input->output, run inside the interpreter (sets up Phase 3 call/cc suspend). flow/start entry point, conformance runner, scoreboard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
29
lib/flow/spec.sx
Normal file
29
lib/flow/spec.sx
Normal file
@@ -0,0 +1,29 @@
|
||||
;; lib/flow/spec.sx — flow combinators as a Scheme prelude.
|
||||
;;
|
||||
;; A flow is a Scheme procedure of one argument: the upstream value.
|
||||
;; node : input -> output
|
||||
;; A leaf node ignoring its argument is effectively a thunk. Combinators
|
||||
;; build composite nodes out of child nodes. The whole flow runs INSIDE the
|
||||
;; Scheme interpreter so that Phase 3's `suspend` (call/cc) can capture the
|
||||
;; flow continuation directly.
|
||||
;;
|
||||
;; Phase 1 combinators:
|
||||
;; (flow-node f) — wrap a 1-arg procedure as a node (identity)
|
||||
;; (flow-id input) — pass the upstream value through unchanged
|
||||
;; (flow-const v) — node that ignores input and yields v
|
||||
;; (sequence n ...) — thread input left-to-right through children
|
||||
;; (parallel n ...) — fan input to every child, join results into a list
|
||||
;; (SEQUENTIAL evaluation; true concurrency is Phase 3)
|
||||
;; (defflow name body)— bind a named flow
|
||||
|
||||
(define
|
||||
flow-combinators-src
|
||||
"(define (flow-node f) f)\n (define (flow-id input) input)\n (define (flow-const v) (lambda (input) v))\n (define (flow-seq-step ns v)\n (if (null? ns) v (flow-seq-step (cdr ns) ((car ns) v))))\n (define sequence (lambda ns (lambda (input) (flow-seq-step ns input))))\n (define parallel (lambda ns (lambda (input) (map (lambda (n) (n input)) ns))))\n (define-syntax defflow\n (syntax-rules ()\n ((defflow nm body) (define nm body))))")
|
||||
|
||||
(define
|
||||
flow-load-combinators!
|
||||
(fn
|
||||
(env)
|
||||
(begin
|
||||
(scheme-eval-program (scheme-parse-all flow-combinators-src) env)
|
||||
env)))
|
||||
Reference in New Issue
Block a user