-
Notifications
You must be signed in to change notification settings - Fork 6k
Clarify F# pattern matching spacing to align with expression formatting #48943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With one suggestion, this is ready for final review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR clarifies the F# style guide's position on spacing conventions for pattern matching to emphasize consistency between expression and pattern formatting. The main issue addressed was whether to use Some(a, b)
or Some (a, b)
in patterns, with the guide now clearly recommending no space before parentheses to match expression formatting.
- Added principle that pattern formatting should match expression formatting for consistency
- Provided comprehensive examples showing correct and incorrect spacing in pattern matching
- Clarified spacing rules for both simple patterns and curried arguments in patterns
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 493969+BillWagner@users.noreply.github.com
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