Skip to content

F# 9, .net 9 type extension of IEnumerable<'T> #18250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wallymathieu opened this issue Jan 20, 2025 · 2 comments
Closed

F# 9, .net 9 type extension of IEnumerable<'T> #18250

wallymathieu opened this issue Jan 20, 2025 · 2 comments

Comments

@wallymathieu
Copy link
Contributor

Please provide a succinct description of the issue.

Repro steps

See documentation for optional-type-extensions:

Create a file such as Extensions.fsx:

module Extensions=
    open System.Collections.Generic

    type IEnumerable<'T> with
        /// Repeat each element of the sequence n times
        member xs.RepeatElements(n: int) =
            seq {
                for x in xs do
                    for _ in 1 .. n -> x
            }

Expected behavior

That the example from the documentation compiles

Actual behavior

Compilation error :

One or more of the declared type parameters for this type extension have a missing or wrong type constraint not matching the original type constraints on 'IEnumerable<_>'F# Compiler[957](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-messages/fs0957)

Known workarounds

  • Use previous version of .net
  • Create a C# extension method

Related information

Provide any related information (optional):

  • Operating system : Windows 11, Mac OS X
  • .NET Runtime kind: .NET Core 9 9.0.101, 9.0.102
  • Editing Tools (Visual Studio Code)
@brianrourkeboll
Copy link
Contributor

I think this is the same as #18001.

@wallymathieu
Copy link
Contributor Author

Yes, it looks like the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants