Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

Fixes #32809

The F# style guide previously only provided formatting guidance for forward pipeline operators (|>), but lacked guidance for reverse pipeline operators (<|). This created uncertainty about how to format multi-line expressions using the reverse pipeline operator.

Changes

Added comprehensive formatting guidance for reverse pipeline operators in the "Formatting pipeline expressions" section:

  • Fantomas-aligned formatting rules: Keep short expressions on a single line, wrap only when line length requires it
  • Practical examples: Shows proper formatting for scenarios where wrapping is justified (long error messages, long function names) and single-line formatting for short expressions
  • Clear guidance: Explicitly states when to use single-line vs multi-line formatting
  • Negative example: Demonstrates what to avoid (unnecessary wrapping of short expressions)
  • Operator reference: Added reverse pipeline operator to the recommended operators list for completeness

Examples added

// ✔️ OK - short expressions stay on one line
let result = someFunction <| arg1 <| arg2 <| arg3

// ✔️ OK - longer expressions can wrap when necessary
failwith
<| sprintf "A very long error message that exceeds reasonable line length: %s - additional details: %s"
    longVariableName
    anotherLongVariableName

// ❌ Not OK - unnecessary wrapping of short expressions
failwith <| sprintf "short: %s"
                    value

The guidance follows the same structure and style as existing pipeline operator documentation and aligns with Fantomas formatting conventions, ensuring consistency across the style guide. All F# code examples have been syntax-validated and tested.

Fixes #21459

Fixes #21459


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/style-guide/formatting.md docs/fsharp/style-guide/formatting

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Sep 24, 2025
@Copilot Copilot AI changed the title [WIP] F# style guidelines: no advice given for reverse pipeline operator Add formatting guidelines for F# reverse pipeline operator Sep 24, 2025
Copilot finished work on behalf of BillWagner September 24, 2025 20:31
@Copilot Copilot AI requested a review from BillWagner September 24, 2025 20:31
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for final review, once I apply suggestions

@BillWagner BillWagner marked this pull request as ready for review September 25, 2025 14:40
@BillWagner BillWagner requested review from a team as code owners September 25, 2025 14:40
@BillWagner BillWagner requested a review from gewarren September 25, 2025 14:41
Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantomas, the commonly used tooling for F# formatting, which is also closely aligned with F# style guide, thinks the opposite for these samples if they are short and fit on a single line.

End of line wrapping is only recommended due to line length limits:

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKB6dZAo5IeD%2BwDyA0gDoBOJAdgGYCGAlgDYDu9ALgBZgA8APmAGcADmXqU21MCUjVYsAEa0yaAKQCwAWjCyFSxQC9VA6eSoRzFy1Z2KKFSlceObe2vtOUPmHPmIQPjIhsYAC2iAICtADmiGAAvIIiYhJSkIhkZLDKYGoANGBIbAyMAkYm9k5WfGDpmWQAsgJRHpWW1YXFxhWt5u1BnS09EH1FTF1mQzz8HWODQyMD3fPT-bP2Xlh4hKT2gcFk4QCujMEJArBhAGKHlNBs9LAO1UpRAIxzk63PZFEATP5LT6Vb5RADMHg2YEAMuRgABysGCxA8dCYrE4U0SonEkmkLmyak02jktgMZUgRN0ZApJLckFy4CgAiC90oUQEqDAAG0GRBQFZIAASNgATyEyDQkGSdJ55kFADdaIxDuKuTKLAAGelOSAASUoSHEAGV6PpkFrHAAWNVgAC6MoAvubedbBSKxRzJeJpfyBQqlSruU5Xk7LJB6rQAB4AGTEiCjiFZnG9jlev3V1rtFkdMr5oaFopVaX1BGoMcoiENIsCyYs8sVyo5gccvxDtYAosXS7Ga6HGNRIBmHSHc7X8%2B6JfI5IwexA6-7G9aIKDW7K9UyyGxLmJFbDEMxGN2VxA2GRlYOs8OXWPC5PYNOV3OG2gm1YLUeoIahLRoIgAEKIWQDgABSUWgwjYdIZ3ME8zysTNzGzCwR1la8PVve8rz9J9VScABWd9IE-b8-wArI41gZh0mgW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D1AaIoCifJ1Q0fHYGkBfEII2kg-2QSRqUAtvQOU5FWTOJSmQGxdiFGuOcKkjxcctF5Qwroju%2Bj05vwHmWOMYF5DwFoE5WA9tWTGNwSks6DThFAxxlk1p-iLC-C7tqa28l6BhHEIqIgiBEBCASQmNgepfwH1uBfIS6UZox1dlQyuHtZkP03kJUEPVtS-mcpQAA1t0gQsNYDw13B5RAfcB64JWQcCIalalWHcSrLKN9qHaJafcvRjhQSv0cJAX8Sh4oHARpg6AogPqFIgvAaSlA1JI2gM5A%2ByTToZRhZzOFNzCwQNrqYg%2B0B3lBErMKasficmWFBCg9F2DWXliOd%2BTlbBuW8qIQfEIYp4CL3pcvRlq8aFej5YTKwoJmHoq2Ts0mv8KkllebQD5XyNKvHVAI20VzNFgLaoiuhDynCgmkei0Zpj7KIBFVAxAY0hCHCSWpUFdsHbvmhS7WFoD4XNK9m0lFhj0UrPSGs-ZiopYfQEKcpw5y-oMhtOaSUAhLj2w5Hm%2B0QA

@BillWagner
Copy link
Member

@copilot Please address #48742 (review) and ensure the samples match the referenced styles in Fantomas

Copilot stopped work on behalf of BillWagner due to an error September 26, 2025 14:32
@BillWagner
Copy link
Member

@copilot Please address #48742 (review) and ensure the samples match the referenced styles in Fantomas

Please start again @copilot

Copy link
Contributor Author

Copilot AI commented Sep 26, 2025

@copilot Please address #48742 (review) and ensure the samples match the referenced styles in Fantomas

Please start again...

I've updated the reverse pipeline operator examples to align with Fantomas formatting conventions. The changes include:

  1. Fixed alignment issue: Corrected the spacing alignment in the multi-line examples
  2. Updated to match Fantomas style: Short expressions now stay on a single line, multi-line formatting is only shown when line length necessitates wrapping
  3. Added clear guidance: Explicitly states to "keep short expressions on a single line" and only wrap "when line length requires wrapping"
  4. Improved examples: Shows practical cases where wrapping is justified (very long error messages, long function/variable names) and what to avoid (unnecessary wrapping of short expressions)

The examples now follow the same philosophy as Fantomas - prefer single-line formatting for readability, wrap only when necessary for line length constraints.

Commit: 16026e1

@Copilot Copilot AI requested a review from BillWagner September 26, 2025 18:34
Copilot finished work on behalf of BillWagner September 26, 2025 18:35
@BillWagner BillWagner merged commit 9022b0d into main Sep 29, 2025
12 checks passed
@BillWagner BillWagner deleted the copilot/fix-7817e228-ac73-4453-87b8-3424718605ce branch September 29, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fsharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

This section should document the order of initialization F# style guidelines: no advice given for reverse pipeline operator
4 participants