From 24ff4187cbd4169540c02dcf0659172c9b127b2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Sep 2025 20:23:00 +0000 Subject: [PATCH 1/4] Initial plan From e5ef5ae590c3187e9e8f03ecc23fcd664182798b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Sep 2025 20:30:27 +0000 Subject: [PATCH 2/4] Add guidance for reverse pipeline operator formatting Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --- docs/fsharp/style-guide/formatting.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index 40646fdd7c289..ef60ac9fd78e6 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -395,6 +395,28 @@ let methods2 = System.AppDomain.CurrentDomain.GetAssemblies() |> Array.concat ``` +For reverse pipeline `<|` operators, place arguments on new lines and align them with the first argument: + +```fsharp +// ✔️ OK +failwith <| sprintf "foobar: %s - foobarbaz: %s" + foobar + foobarbaz + +// ✔️ OK +let message = sprintf "error: %s, details: %s" + <| errorMsg + <| details + +// ✔️ OK +let result = someFunction <| arg1 + <| arg2 + <| arg3 + +// ❌ Not OK +failwith <| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz +``` + ### Formatting lambda expressions When a lambda expression is used as an argument in a multi-line expression, and is followed by other arguments, @@ -571,6 +593,7 @@ The following operators are defined in the F# standard library and should be use ```fsharp // ✔️ OK x |> f // Forward pipeline +f <| x // Reverse pipeline f >> g // Forward composition x |> ignore // Discard away a value x + y // Overloaded addition (including string concatenation) From 6721e3ccebb3912a7fbaa39d161a68c50ef46234 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 25 Sep 2025 10:40:43 -0400 Subject: [PATCH 3/4] Update docs/fsharp/style-guide/formatting.md --- docs/fsharp/style-guide/formatting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index ef60ac9fd78e6..f8459db9812f6 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -410,8 +410,8 @@ let message = sprintf "error: %s, details: %s" // ✔️ OK let result = someFunction <| arg1 - <| arg2 - <| arg3 + <| arg2 + <| arg3 // ❌ Not OK failwith <| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz From 16026e1c93da0eb49fda2c16ca911d33e5f9b5c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:33:47 +0000 Subject: [PATCH 4/4] Update reverse pipeline examples to align with Fantomas formatting conventions Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --- docs/fsharp/style-guide/formatting.md | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index f8459db9812f6..fb7fc61872bd9 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -395,26 +395,28 @@ let methods2 = System.AppDomain.CurrentDomain.GetAssemblies() |> Array.concat ``` -For reverse pipeline `<|` operators, place arguments on new lines and align them with the first argument: +For reverse pipeline `<|` operators, keep short expressions on a single line. When line length requires wrapping, place arguments on new lines and align them consistently: ```fsharp -// ✔️ OK -failwith <| sprintf "foobar: %s - foobarbaz: %s" - foobar - foobarbaz +// ✔️ OK - short expressions stay on one line +let result = someFunction <| arg1 <| arg2 <| arg3 -// ✔️ OK -let message = sprintf "error: %s, details: %s" - <| errorMsg - <| details +// ✔️ 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 -// ✔️ OK -let result = someFunction <| arg1 - <| arg2 - <| arg3 +// ✔️ OK - align continuation lines with the operator +let longResult = + someVeryLongFunctionName + <| firstVeryLongArgumentName + <| secondVeryLongArgumentName + <| thirdVeryLongArgumentName -// ❌ Not OK -failwith <| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz +// ❌ Not OK - unnecessary wrapping of short expressions +failwith <| sprintf "short: %s" + value ``` ### Formatting lambda expressions