Clarify F# pattern matching spacing to align with expression formatting #48943
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #45697 by clarifying the spacing conventions for pattern matching in the F# style guide. The changes emphasize consistency between expression and pattern formatting, specifically addressing whether to use
Some(a, b)
orSome (a, b)
in patterns.Problem
The issue raised a question about spacing before parentheses in pattern matching:
As discussed by @dsyme and @BillWagner, F# style should value consistency between expressions and patterns, and the default formatting (used by Fantomas) does not add spaces before parentheses for uppercase identifiers.
Changes
1. Expression-Pattern Consistency (line ~248)
Added clarification after the application expressions section to establish the principle that pattern formatting should match expression formatting:
2. Pattern Matching Spacing Guidelines (line ~1166)
Added comprehensive guidance in the pattern matching section with clear examples:
No space before parentheses in pattern arguments:
Spaces between curried arguments:
Impact
Fixes #45697
Co-authored-by: BillWagner [email protected]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews