Issue with overloads and lambdas
I'm trying to make this same call: https://github.com/picoe/Eto/blob/develop/Samples/Tutorials/Tutorial4/Main.cs#L55
textBox.TextBinding.BindDataContext<MyObject>(
r => r.TextProperty
, (r, val) => r.TextProperty = val
);
I can write this easily in C#.
To get there in F#, this is what I would initially get working (after trying the same thing as C# code):
textBox.TextBinding.BindDataContext<_>(
Func<MyObject,_>(fun (r) -> r.TextProperty)
, Action<MyObject,_>(fun (r) value -> r.TextProperty <- value)
) |> ignore
With help of more experienced F# user I attempted this:
textBox.TextBinding.BindDataContext<MyObject>(
fun (r : MyObject) -> r.TextProperty
, fun (r: MyObject) value -> r.TextProperty <- value
) |> ignore
which fails due to tuple mishaps (which is easy to troubleshoot), finally settled to
textBox.TextBinding.BindDataContext<_>(
(fun (r : MyObject) -> r.TextProperty)
, (fun (r: MyObject) value -> r.TextProperty <- value)
) |> ignore
Is there something we can do to make C# idiomatic and FP oriented code easy to consume from F#?
This is guaranteed to annoy C# developer trying out to call their nice FP enabled API from F#, at least in cases where overload resolution or type inference significantly differs from C#/VB.NET.
Related
Issue with overloads and lambdas
I'm trying to make this same call: https://github.com/picoe/Eto/blob/develop/Samples/Tutorials/Tutorial4/Main.cs#L55
I can write this easily in C#.
To get there in F#, this is what I would initially get working (after trying the same thing as C# code):
With help of more experienced F# user I attempted this:
which fails due to tuple mishaps (which is easy to troubleshoot), finally settled to
Is there something we can do to make C# idiomatic and FP oriented code easy to consume from F#?
This is guaranteed to annoy C# developer trying out to call their nice FP enabled API from F#, at least in cases where overload resolution or type inference significantly differs from C#/VB.NET.
Related