Support more Tuple shapes in containsOnly - #56
Merged
Conversation
…lter, Union, Append) Generalizes the Head/Last-style <:< evidence to Tuple.Elem[This, N] for an arbitrary index (given lower priority since it can collide with the Head evidence for a literal N=0), and adds containsOnly-preserving givens for Init, Take, Drop, Filter and Append, plus a Union[This] <:< T evidence for the union of all elements. Co-Authored-By: Claude Sonnet 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.
Summary
Head/Last<:<evidence toTuple.Elem[This, N]for an arbitrary index (lower priority thanHead/Last, since it can otherwise collide with them for a literalN=0/last index — verified: they'd reduce to the same type and cause ambiguous givens)containsOnly-preserving givens forTuple.Init,Tuple.Take,Tuple.Drop,Tuple.Filter, andTuple.AppendTuple.Union[This] <:< Tevidence (union of all elements is a subtype ofT)Tuple.FoldandTuple.Splitwere investigated but intentionally left uncovered:Folddepends entirely on an arbitraryFso no sound blanket given exists (only the specificUnioninstantiation is covered);Splitreturns a pair of tuples, each already covered by the newTake/Dropgivens, so it needs no dedicated given.Test plan
scala-cli test .— full suite passes (ContainsOnlyTest: 65/65)Elem/Headambiguity and the fix (lower-priority given) by temporarily removing/reordering and recompilingFilterandUnionwork both for concrete literal tuples and for an abstractval tuple: Tuplewith an explicitcontainsOnlyevidence🤖 Generated with Claude Code