[RFC FS-1035] Discussion: Consistent type directed conversion from functions to .NET delegates #210
Replies: 1 comment 2 replies
-
Not sure this is the correct place to revamp this, but the original issue this appears to have been spawned from was closed as "completed" (fsharp/fslang-suggestions#248), but I believe it either isn't, or only partially has been completed. Furthermore, it appears that the linked RFC by @dsyme (which is now here: https://github.com/fsharp/fslang-design/blob/main/archived/FS-1035-consistent-delegate-type-directed-conversion.md), was archived. To me, this suggests that it's no longer of interest. But if it was implemented, it should not be archived. If it was not implemented, we should perhaps discuss whether we should've archived it in the first place. Here are some examples that currently don't work as well as can be expected (also posted in the issue thread here). Feel free to correct me if I've misunderstood something: type Foo =
static member CallMe (f: Func<string, int, string>) s i =
f.Invoke(s, i)
module Bar =
let printInt s i = $"{s}: {i}"
// this works, but I think that has been so for a while
let res = Foo.CallMe printInt "The value is" 42
// lambda DOES NOT work
let x = Foo.CallMe (fun s i -> $"{s}: {i}") "The value is" 42
// Curried StringFormat DOES NOT work
let y = Foo.CallMe (sprintf "%s: %i") "The value is" 42 Note in particular that the lambda doesn't work here, as the RFC quotes that lambdas always work as a workaround. So either this is a regression (in which case I should turn this into a bug report) or an oversight, in which case we should revisit this RFC. |
Beta Was this translation helpful? Give feedback.
-
Discussion for RFC FS-1035 - Consistent type directed conversion from functions to .NET delegates.
Beta Was this translation helpful? Give feedback.
All reactions