-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
The Syntax section says the syntax for a record is
[ attributes ]
type [accessibility-modifier] typename =
{ [ mutable ] label1 : type1;
[ mutable ] label2 : type2;
... }
[ member-list ]
However, there is something missing. It is also possible to put an access modifier after the equals sign (=
). For example, this code compiles
type Foo = private { bar: int }
For what it is worth, here is one way (in terms of where to put white space in the syntax documentation) to express this
[ attributes ]
type [accessibility-modifier] typename = [accessibility-modifier] {
[ mutable ] label1 : type1;
[ mutable ] label2 : type2;
...
}
[ member-list ]
It is not my intention to change the formatting so much compared to the current syntax. I am still trying to learn what F#'s whitespace requirements are, and this is closest syntax to the current form that I know how to do while also including the missing access modifier.
Edit
I found a syntax that adds this additional access modifier and more closely maintains the existing syntax. Other than adding the additional access modifier, the change is indenting everything that comes after the additional access modifier.
[ attributes ]
type [accessibility-modifier] typename =
[accessibility-modifier]
{ [ mutable ] label1 : type1;
[ mutable ] label2 : type2;
... }
[ member-list ]
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: fe1bc735-dea5-eaf1-8adf-6fa03a43a88e
- Version Independent ID: 76d64ebf-a460-3e86-898f-c31c6c70e354
- Content: Records - F#
- Content Source: docs/fsharp/language-reference/records.md
- Product: dotnet-fsharp
- GitHub Login: @cartermp
- Microsoft Alias: phcart