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/core/whats-new/dotnet-9/overview.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,26 @@ C# 13 ships with the .NET 9 SDK and includes the following new features:
90
90
91
91
For more information, see [What's new in C# 13](../../../csharp/whats-new/csharp-13.md).
92
92
93
+
## F# 9
94
+
95
+
F# 9 ships with the .NET 9 SDK and includes the following new features:
96
+
97
+
- Nullable reference types
98
+
- Discriminated union .Is* properties
99
+
- Partial active patterns can return bool instead of unit option
100
+
- Prefer extension methods to intrinsic properties when arguments are provided
101
+
- Support for empty-bodied computation expressions
102
+
- Hash directives are allowed to take non-string arguments
103
+
- Extended #help directive in fsi to show documentation in the REPL
104
+
- Allow #nowarn to support the FS prefix on error codes to disable warnings
105
+
- Warning about TailCall attribute on non-rec functions or let-bound values
106
+
- Enforce attribute targets
107
+
- Random functions for collections
108
+
- C# collection expression support for F# lists and sets
109
+
- Various quality of life, performance and tooling improvements
110
+
111
+
For more information, see [What's new in F# 9](../../../fsharp/whats-new/fsharp-9.md).
112
+
93
113
## Windows Presentation Foundation
94
114
95
115
Windows Presentation Foundation (WPF) includes support for Windows 11 theming and hyphen-based ligatures. For more information, see [WPF in .NET 9 Preview 4 - Release Notes](https://github.com/dotnet/core/blob/main/release-notes/9.0/preview/preview4/wpf.md).
Copy file name to clipboardExpand all lines: docs/fsharp/whats-new/fsharp-9.md
+44-3Lines changed: 44 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,7 @@ let canSendEmailTo person =
86
86
Previously, partial active patterns returned `Some ()` to indicate a match and `None` otherwise. Now, they can also return `bool`.
87
87
88
88
For example, the active pattern for the following:
89
+
89
90
```fsharp
90
91
match key with
91
92
| CaseInsensitive "foo" -> ...
@@ -154,12 +155,14 @@ This is a more natural syntax compared to the previously available `builder { ()
154
155
Hash directives for the compiler previously only allowed string arguments passed in quotes. Now, they can take any type of argument.
155
156
156
157
Previously, you had:
158
+
157
159
```fsharp
158
160
#nowarn "0070"
159
161
#time "on"
160
162
```
161
163
162
164
Now, you can write:
165
+
163
166
```fsharp
164
167
#nowarn 0070
165
168
#time on
@@ -201,6 +204,7 @@ Previously, when you wanted to disable a warning and wrote `#nowarn "FS0057"`, y
201
204
Now, you won't have to spend time figuring that out because the warning numbers are accepted even with the prefix.
202
205
203
206
All of these will now work:
207
+
204
208
```fsharp
205
209
#nowarn 57
206
210
#nowarn 0057
@@ -218,6 +222,7 @@ It's a good idea to use the same style throughout your project.
218
222
F# now emits a warning when you put the `[<TailCall>]` attribute somewhere it doesn't belong. While it has no effect on what the code does, it could confuse someone reading it.
219
223
220
224
For example, these usages will now emit a warning:
For arrays, there are also `InPlace` variants that shuffle the array in place.
276
+
For arrays, there are also `InPlace` variants that shuffle the items in the existing array instead of creating a new one.
277
+
278
+
```fsharp
272
279
273
280
#### Choice
274
281
@@ -358,7 +365,7 @@ Now, there is an opt-in fix for this behavior available via the `--realsig+` com
358
365
359
366
```xml
360
367
<PropertyGroup>
361
-
<OtherFlags>--realsig+</OtherFlags>
368
+
<RealSig>true</RealSig>
362
369
</PropertyGroup>
363
370
```
364
371
@@ -387,7 +394,40 @@ You can read all the details here: [F# Developer Stories: How we’ve finally fi
387
394
388
395
### Field sharing for struct discriminated unions
389
396
390
-
If fields in multiple cases of a struct discriminated union have the same name and type, they can share the same location, reducing the struct's memory footprint. (Previously, same field names weren't allowed, so there are no issues with binary compatibility.)
397
+
If fields in multiple cases of a struct discriminated union have the same name and type, they can share the same memory location, reducing the struct's memory footprint. (Previously, same field names weren't allowed, so there are no issues with binary compatibility.)
398
+
399
+
For example:
400
+
401
+
```fsharp
402
+
[<Struct>]
403
+
type MyStructDU =
404
+
| Length of int64<meter>
405
+
| Time of int64<second>
406
+
| Temperature of int64<kelvin>
407
+
| Pressure of int64<pascal>
408
+
| Abbrev of TypeAbbreviationForInt64
409
+
| JustPlain of int64
410
+
| MyUnit of int64<MyUnit>
411
+
412
+
sizeof<MyStructDU> // 16 bytes
413
+
```
414
+
415
+
Comparing to previous verion (where you had to use unique field names):
416
+
417
+
```fsharp
418
+
[<Struct>]
419
+
type MyStructDU =
420
+
| Length of length: int64<meter>
421
+
| Time of time: int64<second>
422
+
| Temperature of temperature: int64<kelvin>
423
+
| Pressure of pressure: int64<pascal>
424
+
| Abbrev of abbrev: TypeAbbreviationForInt64
425
+
| JustPlain of plain: int64
426
+
| MyUnit of myUnit: int64<MyUnit>
427
+
428
+
sizeof<MyStructDU> // 60 bytes
429
+
```
430
+
391
431
392
432
### Integral range optimizations
393
433
@@ -426,6 +466,7 @@ This previously opt-in feature has been thoroughly tested and is now enabled by
426
466
Sometimes extra parentheses are used for clarity, but sometimes they are just noise. For the latter case, you now get a code fix in Visual Studio to remove them.
0 commit comments