Is there a way to ‘generate’ functions like this one:
fun x -> x.ToString
I would like to be able to turn an instance method into a static method which takes ‘this’ as a parameter, like so:
items |> Seq.filter my_predicate |> Seq.map Object.ToString
this has been discussed several times on the F# hub. See for example instance methods as functions. This is quite tricky problem, so there are no plans to have something like this in the first version of F# as far as I know, but it would be great to have something like that eventually :-).
Another workaround that you could do is to add static member as an extension method in F#:
But that is a bit ugly. Also, it seems that this works only if you use different name for the method. I guess that F# doesn’t allow you to overload existing method with an extension method and always prefer the intrinsic one.