dotnet / dotnet/docs

F# Flexible Types example out of date

Open
#33,785 0 comments 0 reactions 0 assignees View on GitHub
:watch: Not Triaged okr-freshness okr-quality
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

The F# documentation about [flexible-types.md](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/flexible-types) is not up to date with the latest F# version.

The example states:
```
let iterate1 (f : unit -> seq) =
for e in f() do printfn "%d" e
let iterate2 (f : unit -> #seq) =
for e in f() do printfn "%d" e

// Passing a function that takes a list requires a cast.
iterate1 (fun () -> [1] :> seq)

// Passing a function that takes a list to the version that specifies a
// flexible type as the return value is OK as is.
iterate2 (fun () -> [1])
```
But since F#6 and the [RFC FS-1093](https://github.com/fsharp/fslang-design/blob/main/FSharp-6.0/FS-1093-additional-conversions.md), the cast is not required and the following line works:
```
iterate1 (fun () -> [1])
```

I can propose an update through a PR but I don't know if I should rather:

- Keep this example but emphasize that it's only relevant before F#6.
- Remove it and only keep the relevant seq.concat example.

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: 801ffa68-e3b2-71e7-03e4-1f5ab606e579
* Version Independent ID: a64255fa-049b-02a2-5261-11d675688033
* Content: [Flexible Types - F#](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/flexible-types)
* Content Source: [docs/fsharp/language-reference/flexible-types.md](https://github.com/dotnet/docs/blob/main/docs/fsharp/language-reference/flexible-types.md)
* Product: **dotnet-fsharp**
* GitHub Login: @cartermp
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.