Skip to content

Commit e5ef5ae

Browse files
CopilotBillWagner
andcommitted
Add guidance for reverse pipeline operator formatting
Co-authored-by: BillWagner <[email protected]>
1 parent 24ff418 commit e5ef5ae

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/fsharp/style-guide/formatting.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +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:
399+
400+
```fsharp
401+
// ✔️ OK
402+
failwith <| sprintf "foobar: %s - foobarbaz: %s"
403+
foobar
404+
foobarbaz
405+
406+
// ✔️ OK
407+
let message = sprintf "error: %s, details: %s"
408+
<| errorMsg
409+
<| details
410+
411+
// ✔️ OK
412+
let result = someFunction <| arg1
413+
<| arg2
414+
<| arg3
415+
416+
// ❌ Not OK
417+
failwith <| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz
418+
```
419+
398420
### Formatting lambda expressions
399421

400422
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
571593
```fsharp
572594
// ✔️ OK
573595
x |> f // Forward pipeline
596+
f <| x // Reverse pipeline
574597
f >> g // Forward composition
575598
x |> ignore // Discard away a value
576599
x + y // Overloaded addition (including string concatenation)

0 commit comments

Comments
 (0)