Skip to content

Commit 4c5db39

Browse files
committed
update
1 parent d329193 commit 4c5db39

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

docs/core/whats-new/dotnet-9/overview.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ C# 13 ships with the .NET 9 SDK and includes the following new features:
9090

9191
For more information, see [What's new in C# 13](../../../csharp/whats-new/csharp-13.md).
9292

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+
93113
## Windows Presentation Foundation
94114

95115
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).

docs/fsharp/whats-new/fsharp-9.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ let canSendEmailTo person =
8686
Previously, partial active patterns returned `Some ()` to indicate a match and `None` otherwise. Now, they can also return `bool`.
8787

8888
For example, the active pattern for the following:
89+
8990
```fsharp
9091
match key with
9192
| CaseInsensitive "foo" -> ...
@@ -154,12 +155,14 @@ This is a more natural syntax compared to the previously available `builder { ()
154155
Hash directives for the compiler previously only allowed string arguments passed in quotes. Now, they can take any type of argument.
155156

156157
Previously, you had:
158+
157159
```fsharp
158160
#nowarn "0070"
159161
#time "on"
160162
```
161163

162164
Now, you can write:
165+
163166
```fsharp
164167
#nowarn 0070
165168
#time on
@@ -201,6 +204,7 @@ Previously, when you wanted to disable a warning and wrote `#nowarn "FS0057"`, y
201204
Now, you won't have to spend time figuring that out because the warning numbers are accepted even with the prefix.
202205

203206
All of these will now work:
207+
204208
```fsharp
205209
#nowarn 57
206210
#nowarn 0057
@@ -218,6 +222,7 @@ It's a good idea to use the same style throughout your project.
218222
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.
219223

220224
For example, these usages will now emit a warning:
225+
221226
```fsharp
222227
[<TailCall>]
223228
let someNonRecFun x = x + x
@@ -268,7 +273,9 @@ let allPlayers = [ "Alice"; "Bob"; "Charlie"; "Dave" ]
268273
let round1Order = allPlayers |> List.randomShuffle // [ "Charlie"; "Dave"; "Alice"; "Bob" ]
269274
```
270275

271-
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
272279
273280
#### Choice
274281
@@ -358,7 +365,7 @@ Now, there is an opt-in fix for this behavior available via the `--realsig+` com
358365

359366
```xml
360367
<PropertyGroup>
361-
<OtherFlags>--realsig+</OtherFlags>
368+
<RealSig>true</RealSig>
362369
</PropertyGroup>
363370
```
364371

@@ -387,7 +394,40 @@ You can read all the details here: [F# Developer Stories: How we’ve finally fi
387394

388395
### Field sharing for struct discriminated unions
389396

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+
391431

392432
### Integral range optimizations
393433

@@ -426,6 +466,7 @@ This previously opt-in feature has been thoroughly tested and is now enabled by
426466
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.
427467

428468
For example:
469+
429470
```fsharp
430471
let f (x) = x // -> let f x = x
431472
let _ = (2 * 2) + 3 // -> let _ = 2 * 2 + 3

0 commit comments

Comments
 (0)