Draft: Close #955 - Map key constraint - #1413
Draft
cchantep wants to merge 2 commits into
Draft
Conversation
cchantep
force-pushed
the
fix/955_key_constraint
branch
from
August 31, 2026 21:40
8a951b0 to
9f03b35
Compare
cchantep
force-pushed
the
fix/955_key_constraint
branch
from
August 31, 2026 21:45
9f03b35 to
642320b
Compare
cchantep
force-pushed
the
fix/955_key_constraint
branch
from
August 31, 2026 21:53
642320b to
e3e6432
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.
Pull Request Checklist
Fixes
Fixes #955
Purpose
Fix implicit resolution of
KeyReads/KeyWritesfor types represented as JSON strings.readableKeyReadscurrently derives aKeyReads[T]from anyReads[T]. This is too broad: types such as tuples have aReads, but are not represented as JSON strings and therefore cannot be used as JSON object keys through this mechanism.This PR introduces
Format.Representation[T, R]as explicit evidence that a type has a given JSON representation, and uses it to constrain the string-basedKeyReads/KeyWritesderivation.The existing
readableKeyReadsis kept for backward compatibility but deprecated.Background Context
A
Reads[T]does not imply thatTcan be read from aJsString. For example,Reads[(Int, Int)]exists even though(Int, Int)is not a string representation (unlike for exampleURIwhich is represented as JSON string).The new
Representation[T, JsString]makes this distinction explicit and preventsKeyReads/KeyWritesfrom being derived for types that are not string-represented.Representations for types whose JSON representation depends on the
Writes/Reads(e.g. temporal types, duration, ...) in scope are provided separately throughFormat.Representation.Implicits, so they are opt-in rather than unconditional.