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
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ let myOtherVeryLongValueName =
85
85
The primary reasons for avoiding this are:
86
86
87
87
* Important code is moved far to the right
88
-
* There is less width left for the actual code
88
+
* There's less width left for the actual code
89
89
* Renaming can break the alignment
90
90
91
91
### Avoid extraneous white space
@@ -175,7 +175,7 @@ let update model msg =
175
175
| _ -> model, [ msg ]
176
176
```
177
177
178
-
In summary, prefer parenthesized tuple instantiations, but when using tuples for pattern matching or a return value, it is considered fine to avoid parentheses.
178
+
In summary, prefer parenthesized tuple instantiations, but when using tuples for pattern matching or a return value, it's considered fine to avoid parentheses.
179
179
180
180
### Formatting application expressions
181
181
@@ -245,7 +245,7 @@ SomeClass.Invoke ()
245
245
String.Format (x.IngredientName, x.Quantity)
246
246
```
247
247
248
-
You may need to pass arguments to a function on a new line, as a matter of readability or because the list of arguments or the argument names are too long. In that case, indent one level:
248
+
You may need to pass arguments to a function on a new line as a matter of readability or because the list of arguments or the argument names are too long. In that case, indent one level:
249
249
250
250
```fsharp
251
251
// ✔️ OK
@@ -488,7 +488,7 @@ let subtractThenAdd x = x - 1 + 3
488
488
```
489
489
490
490
Failing to surround a binary `-` operator, when combined with certain formatting choices, could lead to interpreting it as a unary `-`.
491
-
Unary `-` operators should always be immediately followed by the value they are negating:
491
+
Unary `-` operators should always be immediately followed by the value they negate:
492
492
493
493
```fsharp
494
494
// ✔️ OK
@@ -842,7 +842,7 @@ let rainbow2 =
842
842
```
843
843
844
844
You may want to dedicate separate lines for the braces and indent one scope to the right with the expression, however
845
-
code formatters may . In some special cases, such as wrapping a value with an optional without parentheses, you may need to keep a brace on one line:
845
+
code formatters may reformat it. In some special cases, such as wrapping a value with an optional without parentheses, you may need to keep a brace on one line:
846
846
847
847
```fsharp
848
848
// ✔️ OK
@@ -989,7 +989,7 @@ let makeStreamReader x = new System.IO.StreamReader(path = x)
989
989
let makeStreamReader x = new System.IO.StreamReader(path=x)
990
990
```
991
991
992
-
When pattern matching using discriminated unions, named patterns are formatted similarly, e.g.
992
+
When pattern matching using discriminated unions, named patterns are formatted similarly, for example.
993
993
994
994
```fsharp
995
995
type Data =
@@ -1366,7 +1366,7 @@ type PostalAddress =
1366
1366
member x.ZipAndCity = $"{x.Zip} {x.City}"
1367
1367
```
1368
1368
1369
-
Placing the opening token on a new line and the closing token on a new line is preferable if you are declaring interface implementations or members on the record:
1369
+
Placing the opening token on a new line and the closing token on a new line is preferable if you're declaring interface implementations or members on the record:
1370
1370
1371
1371
```fsharp
1372
1372
// ✔️ OK
@@ -1496,7 +1496,7 @@ module A2 =
1496
1496
### Formatting do declarations
1497
1497
1498
1498
In type declarations, module declarations and computation expressions, the use of `do` or `do!` is sometimes required for side-effecting operations.
1499
-
When these span multiple lines, use indentation and a new line to keep the indentation consistent with `let`/`let!`. Here is an example using `do` in a class:
1499
+
When these span multiple lines, use indentation and a new line to keep the indentation consistent with `let`/`let!`. Here's an example using `do` in a class:
1500
1500
1501
1501
```fsharp
1502
1502
// ✔️ OK
@@ -1522,7 +1522,7 @@ type Foo () =
1522
1522
|> theQuickBrownFoxJumpedOverTheLazyDog
1523
1523
```
1524
1524
1525
-
Here is an example with `do!` using two spaces of indentation (because with `do!` there is coincidentally no difference between the approaches when using four spaces of indentation):
1525
+
Here's an example with `do!` using two spaces of indentation (because with `do!` there is coincidentally no difference between the approaches when using four spaces of indentation):
1526
1526
1527
1527
```fsharp
1528
1528
// ✔️ OK
@@ -1869,6 +1869,6 @@ type MyRecord =
1869
1869
1870
1870
When applied to a parameter, they must be on the same line and separated by a `;` separator.
1871
1871
1872
-
### Acknowledgements
1872
+
### Acknowledgments
1873
1873
1874
1874
These guidelines are based on [A comprehensive guide to F# Formatting Conventions](https://github.com/dungpa/fantomas/blob/master/docs/FormattingConventions.md) by [Anh-Dung Phan](https://github.com/dungpa).
0 commit comments