RFC FS-1342 - fst and snd for struct tuples and larger tuples - #844
xperiandri wants to merge 3 commits into
Conversation
Overloaded TupleAccessors members in FSharp.Core, opened implicitly by the compiler under a preview feature, with a generalised argument-tupling rule. Design follows the F# team proposal in fslang-suggestions fsharp#739. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
General guidanceThank you for the work you have put into this RFC. Given its length, we wondered whether AI helped with drafting. If you wrote it by hand, please accept our apologies for that assumption. In either case, we would appreciate a substantially shorter version that preserves the important design details while removing unnecessary repetition. The proposed authoring guidance in #852 can help with this. Its reference sizing table compares existing RFCs by feature complexity, rather than setting hard limits. Shortening should preserve semantic distinctions, safety, and relevant feature interactions. The RFC-specific points below are starting points, not an exhaustive checklist. Please review the document as a whole, by hand or with AI. RFC-specific feedback
Reviewed revision: |
|
@xperiandri, gentle ping on the rewrite request above. Thanks! |
…dance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The RFC changes global name resolution and overload application semantics, requiring final language-design review.
Review effort: Balanced
Findings: None
What changed in this PR
Adds RFC FS-1342, proposing overloaded fst/snd accessors for reference and struct tuples.
Changes:
- Defines
TupleAccessorsoverloads for tuple arities 2–7. - Specifies feature-gated implicit opening and generalized tuple-argument resolution.
- Documents compatibility, tooling, diagnostics, and alternatives.
| File | Description |
|---|---|
RFCs/FS-1342-struct-tuple-fst-snd.md |
Defines the proposed API and compiler behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Adds RFC FS-1342 for the
fst/sndside thread of fslang-suggestions #739, following the overload-based design proposed by @T-Gro in fsharp/fslang-suggestions#739 (comment).Summary of the proposal:
Microsoft.FSharp.Core.TupleAccessorswithstatic member inline fst/sndoverloads for reference and struct tuples of arity 2 to 7; the reference-pair overloads carry[<OverloadResolutionPriority(1)>]solet f x = fst xstill infers'a * 'b -> 'a. Depends on FS-1338.[<AutoOpen>]. Probing a compiler build that includes FS-1338 showed that an auto-opened type makeslet f x = fst xambiguous (FS0041) whenever ORP is off (--langversion:9.0) andfst (1, 2)fail (FS0503) on any compiler without a generalised tupling rule, so a NuGet upgrade of FSharp.Core would break source. Instead a preview featureStructTupleAccessorsmakes the compiler open the type implicitly after FSharp.Core's auto-opens, and generalises the "single named item" argument-tupling rule to overloaded groups of single-parameter methods.Operators.fst/sndstay as they are.Click "Files changed" -> "..." -> "View file" for the rendered RFC.
🤖 Generated with Claude Code