Repository navigation
feat(analyser): type tuples of any length with spread type parameters 🧩 - #572
Conversation
A built-in's signature can declare a type parameter `..R` that stands for a tuple type and spread it into a tuple, as in `<A, ..R>((A, ..R)) -> A`. A tuple among the parameters takes at most one spread, so a call's arguments say what each is. `len`, `first`, `last` and the comparisons take tuples of any length with one signature each instead of one per length up to twelve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f8f61c81a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| parameters: Some(vec![StaticType::unit()]), | ||
| return_type: Box::new(StaticType::Int), | ||
| }, | ||
| "<..A>((..A)) -> Int", |
There was a problem hiding this comment.
Update the tuple manual for the changed built-in signatures
The public tuple API now accepts arbitrary tuple lengths and uses tuple-valued explicit type arguments, such as len::<(Int, String)>((1, "a")), but this commit does not update any manual page. Add the relevant explanation and a runnable example to manual/src/reference/types/tuple.md so users can discover the supported behavior and type-argument syntax. The root AGENTS.md explicitly requires updating the relevant manual page when language behavior changes.
AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
The manual documented both meanings of `++` on tuples: concatenation, which the type checker rejected, and applying `++` to each pair of elements. #296 settled on concatenation, which #572 made possible to type. What changes: - `(1, "a") ++ (2.5, true)` is `(1, "a", 2.5, true)`, a `(Int, String, Float, Bool)`, through one native typed `<..A, ..B>((..A), (..B)) -> (..A, ..B)`. `("a", "b") ++ ("c", "d")` is `("a", "b", "c", "d")`, no longer `("ac", "bd")`. Other operators still apply to each pair of elements. - `++` takes tuples whole, as the comparisons do: `("a", "b") ++ "c"` and `([1], [2]) ++= [3]` are type errors now instead of applying `++` to each element. - `t ++= (4, 5)` is an error for a non-empty right side, as it gives the variable a tuple of another length, which is another type. The error says so. - The manual's tuple page shows `++` with the other tuple operators and drops it from the element-wise examples. The tests of element-wise operators that used `++`, including per-position overloads and in-place `op=`, use `|` on sets, maps, Ints and Bools now. Closes #296. Written with AI (Claude Code), all of it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A built-in's signature couldn't say "a tuple of any length", so
len,first,lastand the comparisons had one overload per tuple length up to twelve, and longer tuples were rejected (#344, #403). This is also the first step towards typing tuple concatenation with++(#296).What changes:
..R, which stands for a tuple type, and spread it into a tuple:lenis<..A>((..A)) -> Int,firstis<A, ..R>((A, ..R)) -> A,lastis<..R, A>((..R, A)) -> A, and<takes<..A>((..A), (..A)). They take tuples of any length, and the per-length overloads are gone.(..A, ..B).len::<(Int, String)>((1, "a")).ndc docsand hover show such a parameter as..R.zipkeeps one overload per number of sequences, up to twelve: spreading parameter lists isn't part of this.Closes #344, closes #403.
Written with AI (Claude Code), all of it.
🤖 Generated with Claude Code
Co-authored-by: Claude Opus 5.5 noreply@anthropic.com