feat(data): port clojure.data's protocols, and diff IR functions structurally - #711
Open
nnunley wants to merge 1 commit into
Open
feat(data): port clojure.data's protocols, and diff IR functions structurally#711nnunley wants to merge 1 commit into
nnunley wants to merge 1 commit into
Conversation
nnunley
force-pushed
the
data-diff-protocols
branch
from
August 11, 2026 01:50
c686813 to
53653b2
Compare
mparrett
approved these changes
Aug 11, 2026
mparrett
left a comment
Collaborator
There was a problem hiding this comment.
No findings.
Checked the protocol rewrite against the old predicate cond (nil, strings vs sequentials, cross-partition), the DiffBox extension path, and fn->data normalization (uses-cache, types via type-of, const values in :aux). Behavior matches what was already there; the Object-default divergence is documented and matches let-go's predicate-shaped collections. CI green on 53653b22.
Collaborator
|
@nnunley Agreed on the literal; same shape as the TinyGo pin, and I’ll leave both as-is at this size. If you’re good with the rest, could you drop an approval on this one? Thanks! |
Port clojure.data's EqualityPartition and Diff extension points while preserving the existing diff behavior. Keep domain-neutral comparison in the canonical clojure.data/data namespace. Add ir.data/fn->data beside the Function representation. It projects headers, blocks, and named inst fields; excludes derived uses state and transient side tables; and reads inferred types through type-of. Consumers compare two projections with clojure.data/diff rather than through a separate ir.diff namespace. Tests cover the canonical clojure.data require/API, foreign protocol extensions, structural IR differences, and projection normalization.
nnunley
force-pushed
the
data-diff-protocols
branch
from
August 11, 2026 23:58
53653b2 to
20bd9ea
Compare
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.
data.lgcarried clojure.data's publicdiffbut not the two protocols it is built on, so the signature matched Clojure while the contract underneath did not — nothing outsidemap?/set?/sequential?could take part. AnirFunction, being an atom, fell through toatom-diffand reported two functions as wholly different rather than structurally so.What changed
EqualityPartitionandDiffare now defined anddiffdispatches through them, matching upstream's shape: compare partitions,diff-similarwhen they agree,atom-diffwhen they do not.One deliberate divergence, documented in the code: upstream reaches the collection families through Java interfaces, but let-go's families are defined by predicates with no shared supertype, so the
Objectdefault consultsmap?/set?/sequential?before falling back to:atom. A new built-in collection therefore classifies correctly without enumerating its concrete type, while any type that extendsEqualityPartitionstill takes precedence.Behaviour is unchanged. Every pre-existing case returns exactly what it did before — I ran all eleven against a build of the old file first, then against the new one.
The extension point, which is the point
ir.diff
ir.diffprojects a Function into comparable data and diffs it, so a difference reports as data rather than as a failed substring match overir.dumptext:versus the 43
strings.Contains(dump, "Add v0 v1 : int")-style assertions inpkg/irtoday.Three things it deliberately normalizes, each because including them reports differences that are not differences: the
:uses-cache/:uses-dirty?memo (two identical fns otherwise disagree on whether anything has asked for uses yet — pinned by a test), the:typestransient (read throughir/type-ofinstead), and the flat:insts/:source-infoside tables (blocks already name the nids they own).The projection is explicit rather than a
Diffimpl because a Function is a barelet-go.lang.Atom— the same type as every other atom — so extending that type would hijack diffing for all of them. Giving Functions their own deftype would fix that, and is tracked separately against #665/EPIC-017.Verification
test/data_diff_test.lg9 tests / 26 assertions,test/ir_diff_test.lg6 / 22, both green. Full.lgsuite,make generateandmake check-generatedgreen. One pre-existing divergence from Clojure is pinned in the test with a comment rather than silently changed:(diff [1 2] [1 2 3])reportsbothas[1 2 nil]here versus Clojure's[1 2], because upstream rebuilds each side from an index map while let-go builds fixed-length vectors.