Skip to content

feat(M5d): ~> function-composition ($f ~> $g) + partial composition + T2006#17

Merged
flearc merged 4 commits into
mainfrom
feature/compose
Jun 23, 2026
Merged

feat(M5d): ~> function-composition ($f ~> $g) + partial composition + T2006#17
flearc merged 4 commits into
mainfrom
feature/compose

Conversation

@flearc

@flearc flearc commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

M5d adds the compose form of the ~> operator — $f ~> $g (when both sides are functions) → a new function λ($x){ $g($f($x)) } — completing the ~> operator (the apply form value ~> $func already shipped). This is the last M5 sub-milestone, closing out the function-signature / $eval / composition arc.

  • Compose branch — in the ~> else path: evaluate the RHS; if it's not a function → T2006; if the LHS is also a function → compose by evaluating a memoized chainAST meta-lambda (function($f,$g){function($x){$g($f($x))}}) and applying it to {lhs, rhs}. The composed result is a real lambda, so it re-composes / curries under further ~> for free.
  • Partial composition — a partial-application RHS ($g(?, x)) is detected by scanning for a ? placeholder and routed through the existing partial machinery (it evaluates to a function value, then composes or single-applies). Delivers $substringAfter(?,"@") ~> $substringBefore(?,".").
  • T200642 ~> "hello" now raises the jsonata error code (was T1006), via a shared M.is_function helper that also backs the partial-application check.

Results

  • Official jsonata suite: 1147 → 1153 / 1682 (+6, 68.6% → 69.0%), zero regressions. The function-applications group goes to 20/22 — the 6 compose cases (005, 009, 012, 015, 016, 017) flip green.
  • 428/428 unit tests green.

Verification

An adversarial fidelity review against a jsonata-js v2.2.1 oracle confirmed compose order (g∘f), re-composition/currying, the T2006 boundary, partial-composition, and input-threading all match. The remaining function-applications failures (case018 parser apply-chain form, case021 regex literals) are out of scope (M7).

Test Plan

  • busted full unit suite — 428/428
  • scripts/run-suite.sh — 1153/1682, zero regressions
  • Adversarial fidelity review vs jsonata-js v2.2.1 oracle

🤖 Generated with Claude Code

flearc and others added 4 commits June 24, 2026 02:14
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…se009/012)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@flearc flearc merged commit 4f5939f into main Jun 23, 2026
1 check passed
@flearc flearc deleted the feature/compose branch June 23, 2026 18:51
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