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
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -468,6 +468,56 @@ let emailMyBossTheLatestResults =
468
468
...
469
469
```
470
470
471
+
### Use camelCase for parameters
472
+
473
+
All parameters should use camelCase in accordance with .NET naming conventions.
474
+
475
+
```fsharp
476
+
module MyModule =
477
+
let myFunction paramOne paramTwo = ...
478
+
479
+
type MyClass() =
480
+
member this.MyMethod(paramOne, paramTwo) = ...
481
+
```
482
+
483
+
### Use PascalCase for modules
484
+
485
+
All modules (top-level, internal, private, nested) should use PascalCase.
486
+
487
+
```fsharp
488
+
module MyTopLevelModule
489
+
490
+
module Helpers =
491
+
module private SuperHelpers =
492
+
...
493
+
494
+
...
495
+
```
496
+
497
+
### Use PascalCase for type declarations, members, and labels
498
+
499
+
Classes, interfaces, structs, enumerations, delegates, records, and discriminated unions should all be named with PascalCase. Members within types and labels for records and discriminated unions should also use PascalCase.
500
+
501
+
```fsharp
502
+
type IMyInterface =
503
+
abstract Something: int
504
+
505
+
type MyClass() =
506
+
member this.MyMethod(x, y) = x + y
507
+
508
+
type MyRecord = { IntVal: int; StringVal: string }
509
+
510
+
type SchoolPerson =
511
+
| Professor
512
+
| Student
513
+
| Advisor
514
+
| Administrator
515
+
```
516
+
517
+
### Use PascalCase for constructs intrinsic to .NET
518
+
519
+
Namespaces, exceptions, events, and project/`.dll` names should also use PascalCase. Not only does this make consumption from other .NET languages feel more natural to consumers, it's also consistent with .NET naming conventions that you are likely to encounter.
520
+
471
521
### Avoid underscores in names
472
522
473
523
Historically, some F# libraries have used underscores in names. However, this is no longer widely accepted, partly because it clashes with .NET naming conventions. That said, some F# programmers use underscores heavily, partly for historical reasons, and tolerance and respect is important. However, be aware that the style is often disliked by others who have a choice about whether to use it.
0 commit comments