Aether 30.1 — operator sections (+ fix a latent JS-backend bug they surfaced)#674
Merged
Merged
Conversation
…urfaced) Adds operator sections as pure parser sugar, desugared in parseParen to a lambda (so the type checker, optimizer and all three backends never see them): - bare operators (+), (*), (::), (|>) => fn a b -> a op b; - right sections (+ 1), (> 0), (:: xs) => fn x -> x op e; - field accessors (.field), chaining as (.a.b) => fn r -> r.field. Left sections are omitted (ambiguous vs partial application); subtract/flip are new prelude companions. The (* *) block-comment syntax collides with a * section, so the lexer carves out the exact (*) as bare multiply and a * right section takes a space, ( * 2). The VM≡JS differential check immediately caught a pre-existing JS-backend bug: a lambda in function position was emitted unparenthesised, so (fn x -> x + 1) 5 compiled to x => body(arg) instead of (x => body)(arg) and the argument was captured by the body. Fixed by parenthesising a lambda in call position; VM≡JS≡WASM holds again. Verification: new 200-program section fuzzer (sectionFuzz.ts) vs an independent reference and the JS backend; 16-case in-app `sections` battery (suite 166 -> 182, WASM 150 -> 166); a gallery example; About/stdlib updates. No regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BSXUJbL86qsEW8zJqvUppq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves the existing
aether-lang-c3d8project. Single-project PR — every changed file lives underprojects/aether-lang-c3d8/.What changed
Adds operator sections — point-free style for
map/filter/foldl— as pure parser sugar, desugared inparseParento an ordinary lambda, so the type checker, the optimizer and all three backends (VM · JS · WASM) never see a section:(+),(*),(::),(|>)⇒fn a b -> a op b(with|>keeping its reverse-application meaning) — ideal as a fold's combiner,foldl (+) 0.(+ 1),(> 0),(:: xs),(^ "!")⇒fn x -> x op e.(.field), chaining as(.a.b)⇒fn r -> r.field— the row-polymorphic projectormap (.name)wants.Left sections are deliberately omitted (they read ambiguously against a partial application);
subtractandflipare new prelude companions ((subtract 1)is the section-can't give, since(- 1)is negation). Aether's(* … *)block comments collide with a*section, so the lexer carves out the exact three-char(*)as bare multiply (sofoldl (*) 1 xslexes) and a*right section takes a space,( * 2)— a documented, principled wart.A real bug the differential suite caught
The VM ≡ JS check immediately flagged that a bare
(op) x y— in fact any(fn …) argat the top level — was miscompiled by the JavaScript backend: it emittedx => body(arg)for(x => body)(arg), so the argument was captured by the body instead of applied to the function. This is a pre-existing latent bug (it fails on(fn x -> x + 1) 5on plainmain) — sections just make the shape trivial to write. Fixed by parenthesising a lambda in function position; VM ≡ JS ≡ WASM holds for it again.Verification
sectionFuzz.ts): random point-free pipelines proved against an independent TypeScript reference and the JS backend — 300/300 across four seeds.sectionsbattery — including the exact shapes that surfaced the JS bug; suite grows 166 → 182, WASM ≡ VM 150 → 166.scripts/verify-project.mjs: scope + conformance + lint +tsc+ build) green locally.A new gallery "Operator sections" example; About feature-list, parser-note and stdlib updates;
JOURNAL.mdcarries the plan and a session-log entry.🤖 Generated with Claude Code
https://claude.ai/code/session_01BSXUJbL86qsEW8zJqvUppq
Generated by Claude Code