Skip to content

Commit e02bc78

Browse files
CopilotBillWagner
andcommitted
Remove misleading nominal types section from anonymous records article
Co-authored-by: BillWagner <[email protected]>
1 parent 8e93b4b commit e02bc78

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

docs/fsharp/language-reference/anonymous-records.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -181,29 +181,6 @@ let data3 = struct {| data2 with Z = r2.X |}
181181

182182
Anonymous records have a number of characteristics that are essential to fully understanding how they can be used.
183183

184-
### Anonymous records are nominal
185-
186-
Anonymous records are [nominal types](https://en.wikipedia.org/wiki/Nominal_type_system). They are best thought of as named [record](records.md) types (which are also nominal) that do not require an up-front declaration.
187-
188-
Consider the following example with two anonymous record declarations:
189-
190-
```fsharp
191-
let x = {| X = 1 |}
192-
let y = {| Y = 1 |}
193-
```
194-
195-
The `x` and `y` values have different types and are not compatible with one another. They are not equatable and they are not comparable. To illustrate this, consider a named record equivalent:
196-
197-
```fsharp
198-
type X = { X: int }
199-
type Y = { Y: int }
200-
201-
let x = { X = 1 }
202-
let y = { Y = 1 }
203-
```
204-
205-
There isn't anything inherently different about anonymous records when compared with their named record equivalents when concerning type equivalency or comparison.
206-
207184
### Anonymous records use structural equality and comparison
208185

209186
Like record types, anonymous records are structurally equatable and comparable. This is only true if all constituent types support equality and comparison, like with record types. To support equality or comparison, two anonymous records must have the same "shape".
@@ -255,7 +232,7 @@ Anonymous records have some restrictions in their usage. Some are inherent to th
255232

256233
Anonymous records do not support pattern matching, unlike named records. There are three reasons:
257234

258-
1. A pattern would have to account for every field of an anonymous record, unlike named record types. This is because anonymous records do not support structural subtyping – they are nominal types.
235+
1. A pattern would have to account for every field of an anonymous record, unlike named record types. This is because anonymous records do not support structural subtyping – they require exact field matching.
259236
2. Because of (1), there is no ability to have additional patterns in a pattern match expression, as each distinct pattern would imply a different anonymous record type.
260237
3. Because of (2), any anonymous record pattern would be more verbose than the use of “dot” notation.
261238

0 commit comments

Comments
 (0)