Trying to derive an Async<Result<'a, 'e>>
from the generic monad CE
#606
-
Hey guys, I'm banging my head with monads & monad transformers. I'm trying to derive a simple asyncResult CE using the generic monad CE. I tried all possible combinations of lift & ReturnT but couldn't get it to compile I'm trying to write a thin wrapper function around HttpClient named sendAsync I'm aware of the task CE available in FSharp but I would like to use async CE, I could either define a I'm stuck with this since 2 days been reading too many things in Haskell & F# but couldn't fix the compiler errors any help is deeply appreciated The first type is
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@gusty I went through a bunch of SO replies you posted & issues on this repo especially this one #135 but still can't figure out how to accomplish what I want |
Beta Was this translation helpful? Give feedback.
-
I'm happy to hear that our work helped you in your road to learning FP, and yes, this library has a proven record of helping C# developers who are curious about FP. Actually there are some links in the docs, like the one you mentioned, please feel free to suggest more links in the docs, specifically where it's needed. |
Beta Was this translation helpful? Give feedback.
Type inference gets tricky with monad transformers and generics in F#.
Anyways, your code is missing some transformations, in the right side of the
let! = ...
there must be aResultT<Async<Result...
.Then in order to get a
ResultT
from aResult
you should useResultT.hoist
.