Skip to content

Fix CanonicalTerm map equality - #218

Merged
Soupstraw merged 2 commits into
masterfrom
jj/map-equality
Nov 3, 2026
Merged

Soupstraw merged 2 commits into
masterfrom
jj/map-equality

Conversation

@Soupstraw

@Soupstraw Soupstraw commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This PR changes the CTMap to use a Set instead of a Map. This way the equality between maps works as described in RFC 8949 §5.6.1:

Two maps are equal if they have the same set of pairs regardless of
their order; pairs are equal if both the key and value are equal.

@Soupstraw
Soupstraw force-pushed the jj/map-equality branch 2 times, most recently from 42cf766 to 006ea48 Compare October 30, 2026 10:28
@Soupstraw
Soupstraw requested a balanced review from Copilot November 2, 2026 12:13
@Soupstraw
Soupstraw requested a review from lehins November 2, 2026 12:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Existing map tests also pass with the old implementation and lack regression coverage for retaining distinct pairs with shared canonical keys, comparison behavior, and collapsing identical canonical pairs.

1 open issue
What changed in this PR

This PR updates canonical CBOR map equality to use sets of key-value pairs, matching the order-independent equality described in RFC 8949 §5.6.1.

Changes:

  • Replace CTMap’s map representation with a set of canonical pairs, removing the duplicate-key exception.
  • Bump the package version to 1.9.0.0 and document the representation change.
File Description
src/​Codec/​CBOR/​Cuddle/​CBOR/​Canonical.hs Store canonical map entries as a set of pairs.
cuddle.cabal Bump the version to 1.9.0.0.
CHANGELOG.md Record the CTMap representation change.

Review effort: Balanced

Comment thread src/Codec/CBOR/Cuddle/CBOR/Canonical.hs Resolved

@neilmayhew neilmayhew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think Copilot's comment should be addressed, either in this PR or a subsequent one

@neilmayhew

Copy link
Copy Markdown
Contributor

I think Copilot's comment should be addressed, either in this PR or a subsequent one

It looks like you're doing just that in #219

@Soupstraw
Soupstraw enabled auto-merge November 3, 2026 14:39
@Soupstraw
Soupstraw merged commit 0b7bbbf into master Nov 3, 2026
10 of 11 checks passed
@Soupstraw
Soupstraw deleted the jj/map-equality branch November 3, 2026 14:42
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.

3 participants