Question about OptionAsync #1207
-
Hi all, I'm just starting out on my functional journey, I'm in awe of this library! I hope to properly understand it all one day. I have a question about using OptionAsync. I think the example below illustrates what I'm trying to do. I have an async method that I want to Bind and therefore I'm looking at OptionAsync rather than Option. The problem is that I'm getting the error below, what's the correct way to handle this? Many thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try to use "return func().ToAsync();" instead. When a task is wrapping a monad, the ToAsync will convert them to the async equivalent. So Task<Either<A,B>> will be converted to EitherAsync<A,B> if you call ToAsync on it. |
Beta Was this translation helpful? Give feedback.
Try to use "return func().ToAsync();" instead. When a task is wrapping a monad, the ToAsync will convert them to the async equivalent. So Task<Either<A,B>> will be converted to EitherAsync<A,B> if you call ToAsync on it.