-
Notifications
You must be signed in to change notification settings - Fork 823
Closed
Description
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
- F# adoption (1 - 4) How to drive F# Adoption - Part 1? #798 How to drive F# Adoption Part 2 #803 How to drive F# Adoption - Part 3 #809 How to drive F# Adoption - Part 4 #1339
- Improve C# to F# interoperability (Discussion: Improve C# to F# interoperability #1254)
Metadata
Metadata
Assignees
Labels
No labels