You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fsharp/style-guide/formatting.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -395,6 +395,30 @@ let methods2 = System.AppDomain.CurrentDomain.GetAssemblies()
395
395
|> Array.concat
396
396
```
397
397
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:
399
+
400
+
```fsharp
401
+
// ✔️ OK - short expressions stay on one line
402
+
let result = someFunction <| arg1 <| arg2 <| arg3
403
+
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
409
+
410
+
// ✔️ OK - align continuation lines with the operator
411
+
let longResult =
412
+
someVeryLongFunctionName
413
+
<| firstVeryLongArgumentName
414
+
<| secondVeryLongArgumentName
415
+
<| thirdVeryLongArgumentName
416
+
417
+
// ❌ Not OK - unnecessary wrapping of short expressions
418
+
failwith <| sprintf "short: %s"
419
+
value
420
+
```
421
+
398
422
### Formatting lambda expressions
399
423
400
424
When a lambda expression is used as an argument in a multi-line expression, and is followed by other arguments,
@@ -571,6 +595,7 @@ The following operators are defined in the F# standard library and should be use
571
595
```fsharp
572
596
// ✔️ OK
573
597
x |> f // Forward pipeline
598
+
f <| x // Reverse pipeline
574
599
f >> g // Forward composition
575
600
x |> ignore // Discard away a value
576
601
x + y // Overloaded addition (including string concatenation)
0 commit comments