Add formatting guidance for multiline lazy expressions in F# #48876
+52
−2
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
Addresses the user question in issue about how to format multiline lazy expressions in F#. The issue asked whether lazy expressions with multiline content should follow the function application rule or the constructor/member invocation rule.
Changes
1. Added "Formatting lazy expressions" section to F# formatting guide
Added a new section in
docs/fsharp/style-guide/formatting.md
that provides clear guidance on formatting both single-line and multiline lazy expressions:Single-line lazy expressions:
Multiline lazy expressions:
The guidance clarifies that lazy expressions follow the function application pattern: the opening parenthesis remains on the same line as the
lazy
keyword, with the expression body indented one level and the closing parenthesis aligned with the opening.2. Enhanced lazy expressions reference documentation
Updated
docs/fsharp/language-reference/lazy-expressions.md
to include:Resolution
This provides the answer to the user's question: multiline lazy expressions should follow the function application rule, with the pattern
lazy (
keeping the opening parenthesis on the same line aslazy
, which is consistent with other function applications that have multiline arguments in the F# style guide.Fixes #<issue_number>
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