Skip to content

Commit 16026e1

Browse files
CopilotBillWagner
andcommitted
Update reverse pipeline examples to align with Fantomas formatting conventions
Co-authored-by: BillWagner <[email protected]>
1 parent 6721e3c commit 16026e1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

docs/fsharp/style-guide/formatting.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,26 +395,28 @@ let methods2 = System.AppDomain.CurrentDomain.GetAssemblies()
395395
|> Array.concat
396396
```
397397

398-
For reverse pipeline `<|` operators, place arguments on new lines and align them with the first argument:
398+
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:
399399

400400
```fsharp
401-
// ✔️ OK
402-
failwith <| sprintf "foobar: %s - foobarbaz: %s"
403-
foobar
404-
foobarbaz
401+
// ✔️ OK - short expressions stay on one line
402+
let result = someFunction <| arg1 <| arg2 <| arg3
405403
406-
// ✔️ OK
407-
let message = sprintf "error: %s, details: %s"
408-
<| errorMsg
409-
<| details
404+
// ✔️ OK - longer expressions can wrap when necessary
405+
failwith
406+
<| sprintf "A very long error message that exceeds reasonable line length: %s - additional details: %s"
407+
longVariableName
408+
anotherLongVariableName
410409
411-
// ✔️ OK
412-
let result = someFunction <| arg1
413-
<| arg2
414-
<| arg3
410+
// ✔️ OK - align continuation lines with the operator
411+
let longResult =
412+
someVeryLongFunctionName
413+
<| firstVeryLongArgumentName
414+
<| secondVeryLongArgumentName
415+
<| thirdVeryLongArgumentName
415416
416-
// ❌ Not OK
417-
failwith <| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz
417+
// ❌ Not OK - unnecessary wrapping of short expressions
418+
failwith <| sprintf "short: %s"
419+
value
418420
```
419421

420422
### Formatting lambda expressions

0 commit comments

Comments
 (0)