Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default type inference mismatch? #18

Open
piaste opened this issue Dec 8, 2020 · 0 comments
Open

Default type inference mismatch? #18

piaste opened this issue Dec 8, 2020 · 0 comments

Comments

@piaste
Copy link

piaste commented Dec 8, 2020

I've been moving some code from Taskbuilder.fs to Ply and I've noticed an odd compilation error.

It seems that when the type of an expression unwrapped with let! is unspecified, it is always inferred as Ply<'t>.

Naturally, if I'm not using the uply builder, that's unlikely to be the default that I want, especially since it's an "unsafe" builder.

I'm much more likely to be composing the same kind of CE all the way through. But then I get a compile error at the call site because the let! expects a Ply<_> unless explicitly annotated.

Would it be possible to make each builder choose its own type as the default inference target for let! and other unwrappings?

Minimal repro

open FSharp.Control.Tasks

let higherOrderTask t = task {
    let! result = t()    
    return result + "_1"
}

let someTask () = System.IO.File.ReadAllTextAsync("/somePath")

let instance = higherOrderTask someTask
(* someTask: Type mismatch. Expecting a
    'unit -> Ply.Ply<string>'    
but given a
    'unit -> Task<string>'
*)

Current workaround:

    let! result = (t() : Task<_>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant