FsToolkit.ErrorHandling icon indicating copy to clipboard operation
FsToolkit.ErrorHandling copied to clipboard

Overload issues with TaskResult on generic functions

Open abelbraaksma opened this issue 2 years ago • 1 comments

Describe the bug

A function that takes a function as parameter cannot have its result bound with let! or do!, whereas the same works with task just fine.

To Reproduce

    let testTR someFunction = taskResult {
        let! x = someFunction()
        return x
    }

Expected behavior

No exception, as with task. I.e., the following works:

    let testTR someFunction = task {
        let! x = someFunction()
        return x
    }

Here, someFunction is inferred to be of unit -> #Task<_>. Similarly, with TaskResult, I'd expect something like unit -> #TaskResult<_, _> to be the top pick.

Desktop (please complete the following information):

  • OS: Windows, Linux, MacOS
  • Version: any, afaik

Additional context

I realize this request may be considered dubious. After all, TaskResult accepts several concrete types, and if no information is given, which one should be chosen, right?

But the same could be said for task, which accepts task-like, ValueTask and Task/Task<_>.

My guess is that this can be solved by slightly changing the priorities in the overload resolution, but I haven't tried that yet myself. If "impossible", or considered too ambiguous a request, I won't lose sleep over it, promised! :)

abelbraaksma avatar Dec 21 '22 17:12 abelbraaksma

Yeah it's probably an overload resolution issue This may be a consequence of the Source member overloads as well. I'm definitely willing to take a PR for this :)

TheAngryByrd avatar Dec 21 '22 19:12 TheAngryByrd

Will be available in v5

TheAngryByrd avatar Apr 06 '24 16:04 TheAngryByrd