Skip to content

Commit 54464ad

Browse files
abonieBillWagner
andauthored
What's new in F# 10 (#49649)
* What's new in F# 10 * Add ai-usage metadata * Add link in .net 10 overview to F# * Apply suggestions from code review Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com> * Add links to language reference * Add entries about *Final methods to CE reference * Update parameters page with voption for optional param info * Apply review feedback * Add type cache section * Add Whats New F#10 to the ToC --------- Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
1 parent fdea82f commit 54464ad

File tree

6 files changed

+420
-1
lines changed

6 files changed

+420
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The F# updates in .NET 10 include several new features and improvements across t
7575

7676
General improvements and bug fixes in the compiler implementation.
7777

78-
For more information, see the [F# release notes](https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html).
78+
For more information, see [What's new in F# 10](../../../fsharp/whats-new/fsharp-10.md) or the [F# release notes](https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html).
7979

8080
## Visual Basic
8181

docs/fsharp/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ landingContent:
120120
linkLists:
121121
- linkListType: whats-new
122122
links:
123+
- text: "What's new in F# 10"
124+
url: whats-new/fsharp-10.md
123125
- text: "What's new in F# 9"
124126
url: whats-new/fsharp-9.md
125127
- text: "What's new in F# 8"

docs/fsharp/language-reference/computation-expressions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ The following table describes methods that can be used in a workflow builder cla
264264
|`Delay`|`(unit -> M<'T>) -> Delayed<'T>`|Wraps a computation expression as a function. `Delayed<'T>` can be any type, commonly `M<'T>` or `unit -> M<'T>` are used. The default implementation returns a `M<'T>`.|
265265
|`Return`|`'T -> M<'T>`|Called for `return` in computation expressions.|
266266
|`ReturnFrom`|`M<'T> -> M<'T>`|Called for `return!` in computation expressions.|
267+
|`ReturnFromFinal`|`M<'T> -> M<'T>`|If present, called for `return!` and `do!` when in tail-call position.|
267268
|`BindReturn`|`(M<'T1> * ('T1 -> 'T2)) -> M<'T2>`|Called for an efficient `let! ... return` in computation expressions.|
268269
|`BindNReturn`|`(M<'T1> * M<'T2> * ... * M<'TN> * ('T1 * 'T2 ... * 'TN -> M<'U>)) -> M<'U>`|Called for efficient `let! ... and! ... return` in computation expressions without merging inputs.<br /><br />for example, `Bind3Return`, `Bind4Return`.|
269270
|`MergeSources`|`(M<'T1> * M<'T2>) -> M<'T1 * 'T2>`|Called for `and!` in computation expressions.|
@@ -277,6 +278,7 @@ The following table describes methods that can be used in a workflow builder cla
277278
|`While`|`(unit -> bool) * Delayed<'T> -> M<'T>`or<br /><br />`(unit -> bool) * Delayed<unit> -> M<unit>`|Called for `while...do` expressions in computation expressions.|
278279
|`Yield`|`'T -> M<'T>`|Called for `yield` expressions in computation expressions.|
279280
|`YieldFrom`|`M<'T> -> M<'T>`|Called for `yield!` expressions in computation expressions.|
281+
|`YieldFromFinal`|`M<'T> -> M<'T>`|If present, called for `yield!` when in tail-call position and in case of `do!` in tail-call position as a fallback for `ReturnFromFinal`|
280282
|`Zero`|`unit -> M<'T>`|Called for empty `else` branches of `if...then` expressions in computation expressions.|
281283
|`Quote`|`Quotations.Expr<'T> -> Quotations.Expr<'T>`|Indicates that the computation expression is passed to the `Run` member as a quotation. It translates all instances of a computation into a quotation.|
282284

docs/fsharp/language-reference/parameters-and-arguments.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ Baud Rate: 9600 Duplex: Full Parity: false
150150
Baud Rate: 4800 Duplex: Half Parity: false
151151
```
152152

153+
You can also specify an optional parameter to be a [Value Option](./value-options.md) type by applying a `[<Struct>]` attribute to it.
154+
155+
```fsharp
156+
type T() =
157+
static member M([<Struct>] ?p : string) =
158+
match p with
159+
| ValueSome s -> printfn "%s" s
160+
| ValueNone -> printfn "None"
161+
```
162+
163+
When using struct-backed optional parameter, as seen above, you would use `defaultValueArg` instead of `defaultArg` to set the default value of the parameter.
164+
153165
### Optional parameters (C# interop)
154166

155167
For the purposes of C# interop, you can use the attributes `[<Optional; DefaultParameterValue<(...)>]` in F#, so that callers will see an argument as optional. This is equivalent to defining the argument as optional in C# as in `MyMethod(int i = 3)`. This form was introduced in F# 4.1 to help facilitate interoperation with C# code.

docs/fsharp/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ items:
292292
href: tutorials/using-functions.md
293293
- name: What's new
294294
items:
295+
- name: F# 10
296+
href: whats-new/fsharp-10.md
295297
- name: F# 9
296298
href: whats-new/fsharp-9.md
297299
- name: F# 8

0 commit comments

Comments
 (0)