Skip to content

Support more Tuple shapes in containsOnly - #56

Merged
halotukozak merged 2 commits into
mainfrom
feature/containsonly-more-forms
Sep 4, 2026
Merged

Support more Tuple shapes in containsOnly#56
halotukozak merged 2 commits into
mainfrom
feature/containsonly-more-forms

Conversation

@halotukozak

Copy link
Copy Markdown
Collaborator

Summary

  • Generalizes Head/Last <:< evidence to Tuple.Elem[This, N] for an arbitrary index (lower priority than Head/Last, since it can otherwise collide with them for a literal N=0/last index — verified: they'd reduce to the same type and cause ambiguous givens)
  • Adds containsOnly-preserving givens for Tuple.Init, Tuple.Take, Tuple.Drop, Tuple.Filter, and Tuple.Append
  • Adds a Tuple.Union[This] <:< T evidence (union of all elements is a subtype of T)
  • Tuple.Fold and Tuple.Split were investigated but intentionally left uncovered: Fold depends entirely on an arbitrary F so no sound blanket given exists (only the specific Union instantiation is covered); Split returns a pair of tuples, each already covered by the new Take/Drop givens, so it needs no dedicated given.

Test plan

  • scala-cli test . — full suite passes (ContainsOnlyTest: 65/65)
  • Verified the Elem/Head ambiguity and the fix (lower-priority given) by temporarily removing/reordering and recompiling
  • Verified Filter and Union work both for concrete literal tuples and for an abstract val tuple: Tuple with an explicit containsOnly evidence

🤖 Generated with Claude Code

…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>
Copilot AI lite review requested due to automatic review settings September 4, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@halotukozak
halotukozak merged commit 17018fe into main Sep 4, 2026
8 checks passed
@halotukozak
halotukozak deleted the feature/containsonly-more-forms branch September 4, 2026 18:58
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.

2 participants