Repository navigation
DDIR: slots written as corgi lambdas - #930
Merged
Merged
Conversation
In corgi's ML frontend, parentheses build a tuple in expressions and patterns, as they do in shapes: `(e)` is a one-field tuple and `()` the unit, and a tuple pattern takes apart exactly its fields. Corgi's effect system is gone: checked ops are words that return a sum, and the plain names are the lossy ops. `Builder::graft` inlines a graph at an existing node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any term slot may be a corgi lambda, `pat -> body`, in corgi's ML syntax: it runs `let pat = input in body` with `input` the tuple of the slot's rows, `(key, val)` for a linear op and `(key, left val, right val)` for a join. In `key`, `map`, and `join` the body gives the pair `(key, val)`; in `value`, `filter`, `flatmap`, and `enter_at` it gives the one value. For example, `key(((src, dst), ()) -> ((src), (dst)))` is `key($0[0] ; $0[1])`. The lexer takes a lambda's text whole, since corgi's syntax is not DDIR's: a parenthesized group with a `->` outside nested brackets is a lambda, from after the group's last comma before the arrow. A lambda is `Term::Corgi(src, args)`. The corgi backend parses it once and grafts its graph into the operator's, and `lower` now runs corgi's CSE, so a lambda that gives both key and val runs once. The row backend runs it on one row at a time. Parse and shape errors, including a pattern that does not fit its rows, are reported at install. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Any term slot may now be a corgi lambda,
pat -> body, in corgi's ML syntax. It runslet pat = input in bodywithinputthe tuple of the slot's rows:(key, val)for a linear op,(key, left val, right val)for a join. Inkey,map, andjointhe body gives(key, val); invalue,filter,flatmap, andenter_atit gives the one value.Commits
(e)a one-field tuple,()the unit), and a tuple pattern takes apart exactly its fields. The effect system is gone (checked ops are words returning a sum; DDIR's out-of-range index already read the zero, so nothing changes there).Builder::graftinlines a graph at a node. Replaces Bump corgi to WIP f20264a: one-field tuples, the unit, checked words, graft #928.parse/pipe.rs): a parenthesized group with a->outside nested brackets is a lambda, taken as raw text from after the group's last comma before the arrow, sojoin(other, pat -> body)works. Corgi's syntax (.2, floats,#comments) is never lexed as DDIR.Term::Corgi(src, args)(ir.rs):argsare the slot's rows.corgi/logic.rs): the program is parsed once and grafted into the operator's graph;lowernow runscorgi::cse, so a lambda giving both key and val runs once (checked: 16 nodes where two copies would be 25).the pattern (_) takes apart a product of 1 field, not (Int, Int).Tests
tests/corgi_lambdas.rs: reach, SCC, and the single-term slots written both ways agree on the vec backend and on corgi at 1 and 3 workers; mismatched patterns, non-integer predicates, and parse errors are refused at install.tests/explain.rs: explanations of a lambda program are sufficient, and agree between backends.cargo test -p interactive --lib --testsand theddir-servertests pass.🤖 Generated with Claude Code