Skip to content

Conversation

@rssh
Copy link
Contributor

@rssh rssh commented Dec 31, 2025

This implements uniform tuple construction and extraction:

Tuple.apply:
- transparent inline macro that preserves element types
- Works for any arity (0 to 22+)
- Tuple() returns EmptyTuple
- Tuple(x) returns Tuple1[T]
- Tuple(x, y, ...) returns (T1, T2, ...)

Tuple.unapply:
- Typed overloads for Tuple1-Tuple22 with precise element types
- unapplySeq fallback for abstract Tuple types (runtime arity matching)
- Enables: case Tuple(a, b) => with typed extraction for concrete types

REPL:
- Display Tuple1 as "Tuple1(x)" instead of pprint's "(x,)" format
@rssh rssh requested a review from a team as a code owner December 31, 2025 16:00
@rssh rssh changed the title Add uniform Tuple.apply and Tuple.unapply for SIP-NN Add uniform Tuple.apply and Tuple.unapply Dec 31, 2025
@rssh rssh force-pushed the uniform-tuple-apply-unapply branch from b4c648b to 13e02ae Compare January 1, 2026 22:25
rssh added 2 commits January 2, 2026 12:38
When matching on abstract Tuple with case Tuple(), the unapplySeq
extractor is used. The exhaustivity checker didn't understand that
Tuple() via unapplySeq covers EmptyTuple.

This adds special handling in the pattern space projection to map
Tuple.unapplySeq with empty patterns directly to Typ(EmptyTuple),
allowing the exhaustivity checker to correctly determine that
case Tuple() covers the EmptyTuple case.
@rssh rssh force-pushed the uniform-tuple-apply-unapply branch from ab4450c to 5371f23 Compare January 2, 2026 11:18
@Gedochao Gedochao added stat:feature freeze Issues and PRs waiting for the feature freeze to be lifted. stat:needs decision Some aspects of this issue need a decision from the maintainance team. and removed stat:needs decision Some aspects of this issue need a decision from the maintainance team. labels Jan 2, 2026
@rssh rssh force-pushed the uniform-tuple-apply-unapply branch from 5371f23 to 456f34d Compare January 2, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat:feature freeze Issues and PRs waiting for the feature freeze to be lifted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants