Skip to content

v4 std/node: add fold_node catamorphism - #3297

Merged
briansrls merged 1 commit into
mainfrom
session/smart-badger-617
May 18, 2026
Merged

briansrls merged 1 commit into
mainfrom
session/smart-badger-617

Conversation

@briansrls

@briansrls briansrls commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add the T-1 NodeFold<R> algebra and fold_node catamorphism to src/v4/std/node.dag
  • migrate node_well_formed onto the shared node fold instead of hand-rolled recursive descent
  • update the dissolution inventory to mark only that walker closed while leaving resolver harvest walkers tracked

Validation

  • cargo test -p v3-compiler v4_std_fact_density_dag_compiles -- --nocapture via BuildBuddy

@briansrls briansrls changed the title 🟡 burn-down lane closeout v4 std/node: add fold_node catamorphism May 18, 2026
@briansrls
briansrls marked this pull request as ready for review May 18, 2026 07:00
@briansrls

briansrls commented May 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Verified the optional evaluation-order note against the current code. It is mechanically true that this fold_node evaluates the child fold before calling step, so it is not a lazy short-circuiting validation combinator. I do not think that is a blocking issue for this PR: node_well_formed is a pure Bool over the finite Node structure, has no diagnostic side channel, and the substrate primitive being introduced here is the full structural catamorphism named by the dissolution registry. A short-circuiting validation/traverse form would be a separate effect/validation combinator, not this fold_node primitive. — sent from smart-badger-617

@briansrls
briansrls merged commit 7af04eb into main May 18, 2026
14 checks passed
briansrls added a commit that referenced this pull request May 19, 2026
Adds NodeFold<R> + fold_node to 00_core.dag (v2.std.core) — the structural
fold over a Node tree, mirroring src/v4/std/node.dag fold_node (#3297).
expr_has_self_call was a hand-rolled any-descendant recursion over
Node.children (Practice-10 walker dissolution); it is now derived as a
fold_node disjunction. expr_has_non_tail_self_call stays a hand-written
recursion — genuinely irregular (tail position flips per expr kind), a
clean 🟢, not a catamorphism candidate.

Verified: 00_core.dag parses, resolves, typechecks and emits with 0
diagnostics; fold_node's recursion passes the v2 complexity analyzer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request May 22, 2026
…3564)

Operator-direct prefix-drop sweep mirroring fold_node precedent
(#3297) and the free_monoid_* sweep (#3472). Rename only — no
semantics change. Touches the v4 algebra.dag definition + all
v4.std.algebra imports/callsites in extdeps/formats/sql.dag and
extdeps/languages/{cpp,python,rust}.dag, plus two 🟡-gated comment
references in algebra.dag ("fold_list laundering"). v3 spec/std
identifiers (`*_language_spec_free_monoid_fold_contract`) and
archival narrative in docs/design-dissolution-lens.md are out of
scope for a v4 substrate rename.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant