Skip to content

RFC FS-1342 - fst and snd for struct tuples and larger tuples - #844

Open
xperiandri wants to merge 3 commits into
fsharp:mainfrom
xperiandri:rfc/fs-1342-struct-tuple-fst-snd
Open

xperiandri wants to merge 3 commits into
fsharp:mainfrom
xperiandri:rfc/fs-1342-struct-tuple-fst-snd

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

Adds RFC FS-1342 for the fst/snd side 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.TupleAccessors with static member inline fst/snd overloads for reference and struct tuples of arity 2 to 7; the reference-pair overloads carry [<OverloadResolutionPriority(1)>] so let f x = fst x still infers 'a * 'b -> 'a. Depends on FS-1338.
  • The type is not [<AutoOpen>]. Probing a compiler build that includes FS-1338 showed that an auto-opened type makes let f x = fst x ambiguous (FS0041) whenever ORP is off (--langversion:9.0) and fst (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 feature StructTupleAccessors makes 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/snd stay as they are.

Click "Files changed" -> "..." -> "View file" for the rendered RFC.

🤖 Generated with Claude Code

xperiandri and others added 2 commits September 5, 2026 22:35
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>
@T-Gro

T-Gro commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

General guidance

Thank 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

  • Not needed: Compiler patch, baseline, and test-file inventory
  • Repeated: implicit-opening, argument-tupling, and promotion rules

Reviewed revision: e273450.

@T-Gro T-Gro added the AI-Review-1-screening-redo Stage 1: scope or RFC quality needs revision. No design or human review yet. label Sep 10, 2026
@T-Gro

T-Gro commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@xperiandri, gentle ping on the rewrite request above. Thanks!

…dance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 20:13

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 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 TupleAccessors overloads 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Review-1-screening-redo Stage 1: scope or RFC quality needs revision. No design or human review yet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants