Skip to content

Conversation

@qnikst
Copy link
Contributor

@qnikst qnikst commented Nov 3, 2025

Previously in a code we required entire value to have an Ord instance. While it's possible to have such one it leads to problems when we work with generic values of the types we do not know.

The other problem is that during the computation we should check the equality for the keys only and do not allow two values with the same key even if they are not equal. So the new type reflects that properly.

Previously in a code we required entire value to have an Ord
instance. While it's possible to have such one it leads to problems
when we work with generic values of the types we do not know.

The other problem is that during the computation we should check
the equality for the keys only and do not allow two values with
the same key even if they are not equal. So the new type reflects
that properly.
@qnikst qnikst requested review from Copilot and joaosreis November 3, 2025 15:14
@qnikst qnikst self-assigned this Nov 3, 2025
@qnikst qnikst added the bug Something isn't working label Nov 3, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors constraint handling in serialization code to support types with separate key types. Instead of requiring the entire type a to be Ord, it changes constraints to require Ord (Key a), where Key a is the associated type from the HasKey typeclass.

  • Changed type constraints from Ord a to Ord (Key a) throughout serialization interfaces
  • Updated sorting logic to use sortBy (compare \on` getKey)instead of directsort`
  • Extracted common finalization logic into a named helper function finalizeVector in External/Impl.hs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scls-format/src/Cardano/SCLS/Internal/Serializer/Reference/Impl.hs Updated type constraints and sorting to use keys; added Data.Function (on) import
scls-format/src/Cardano/SCLS/Internal/Serializer/External/Impl.hs Updated type constraints, added on to imports, refactored duplicate sorting code into finalizeVector helper

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants