Skip to content

F# Flexible Types example out of date #33785

@LePelicaN

Description

@LePelicaN

The F# documentation about flexible-types.md is not up to date with the latest F# version.

The example states:

let iterate1 (f : unit -> seq<int>) =
    for e in f() do printfn "%d" e
let iterate2 (f : unit -> #seq<int>) =
    for e in f() do printfn "%d" e

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

// 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, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⌚ Not TriagedNot triagedokr-freshnessOKR: Freshness of contentokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions