Skip to content
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

ToFSharpFunc(Func) missing in .NET Core #1847

Closed
ruxo opened this issue Nov 26, 2016 · 9 comments
Closed

ToFSharpFunc(Func) missing in .NET Core #1847

ruxo opened this issue Nov 26, 2016 · 9 comments
Labels
Area-Library Issues for FSharp.Core not covered elsewhere Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@ruxo
Copy link

ruxo commented Nov 26, 2016

Hi,

I have an issue with using FuncConvert.ToFSharpFunc. For example:

let h = FuncConvert.ToFSharpFunc<int,int>

This will cause following compilation error:

error FS0502: The member or object constructor 'ToFSharpFunc' takes 1 type argument(s) but is here given 2. The required signature is 'static member FuncConvert.ToFSharpFunc : action:Action<'T> -> ('T -> unit)'

.NET CLI: 1.0.0-preview2-1-003177
Compiler Version: dotnet-compile-fsc/1.0.0-preview2-020000
dotNET Core Version: 1.1.0

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

@ruxo Right now the overload set is different on FSharp.Core, the "Converter" overload is not available.

#if !FX_NO_CONVERTER
        /// <summary>Convert the given Converter delegate object to an F# function value</summary>
        /// <param name="converter">The input Converter.</param>
        /// <returns>The F# function.</returns>
        static member  ToFSharpFunc       : converter:Converter<'T,'U>          -> ('T -> 'U)
#endif

There does indeed need to be some kind of replacement for this overload using System.Func. We may need to use a different name to make sure we can provide it on .NET Framework too without breaking existing code.

@dsyme dsyme added Area-Library Issues for FSharp.Core not covered elsewhere Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Nov 26, 2016
@ruxo
Copy link
Author

ruxo commented Nov 26, 2016

@dsyme Yes, I noticed that. But there exists another version that uses Func<T1,T2> instead. This one can be listed by reflection but cannot be resolved by the compiler.

@dsyme
Copy link
Contributor

dsyme commented Nov 26, 2016

@ruxo Yes, you are correct that the Func version is not revealed in the signature. It should be

@dsyme dsyme changed the title FSC compiler cannot resolve the correct overload function. ToSharpFunc(Func) missing in .NET Core Apr 29, 2017
@dsyme dsyme changed the title ToSharpFunc(Func) missing in .NET Core ToFSharpFunc(Func) missing in .NET Core Apr 29, 2017
@dsyme
Copy link
Contributor

dsyme commented Dec 8, 2017

@KevinRansom @cartermp My original proposed solution for this was to add Func-based overloads to the ToFSharpFunc API. It would be a nice addition however it's a breaking change for C# callers.

The approach I recommend is to keep the FuncConvert API the same as it has always been and to have a .NET Standard 2.0 build of FSharp.Core (where System.Converter is available).

I’ve forgotten – where are we on a .NET Standard 2.0 build of FSharp.Core?

@dsyme
Copy link
Contributor

dsyme commented Mar 9, 2018

This is causing problems in practice, see #4470

@KevinRansom again mentioning that this strongly motivates having a .NET Standard 2.0-specific cut of FSharp.Core.

@cartermp
Copy link
Contributor

@KevinRansom @dsyme let's pull the trigger on dropping netstandard1.6 support for FSharp.Core and unblocking this by making FSharp.Core netstandard2.0/net45 only. .NET Core 1.x is officially out of support starting July of this year, so there is no real reason for people to continue using F# vNext as a netstandard1.6 component.

We should also look at #6128 to see if it's related.

@realvictorprm
Copy link
Contributor

so what is the status of this?

@cartermp cartermp modified the milestones: Backlog, .NET Core 3.0 Jul 11, 2019
@cartermp
Copy link
Contributor

#6814

@realvictorprm
Copy link
Contributor

Nice, thank you @cartermp!

@cartermp cartermp modified the milestones: .NET Core 3.0, 16.3 Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Library Issues for FSharp.Core not covered elsewhere Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

No branches or pull requests

4 participants