Awaiting OptionAsync / EitherAsync #960
Unanswered
BrunoJuchli
asked this question in
Q&A
Replies: 1 comment
-
I forgot to check discussions before writing up #1019 You can await an edit: copying link to an issue which explains the async/await limitation: dotnet/csharplang#3723 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
EitherAsync
In contrast to
OptionAsync<A>
,EitherAsync<L,R>
can't be await because it's missing theAsyncMethodBuilderAttribute
-- well it's actually commented out as can be seen here:language-ext/LanguageExt.Core/Monads/Alternative Value Monads/Either/EitherAsync/EitherAsync.cs
Line 35 in d5248b6
Is there a plan to add that later on? Are there significant obstacles to doing so or would a PR be accepted?
(I'd expect awaiting an
EitherAsync<L,R>
to return anEither<L,R>
).OptionAsync
Why does awaiting an
OptionAsync<A>
returnA?
and notOption<A>
?The questions arose in the context of a unit test, like:
Now for the test it doesn't matter that much, I can usually just test for
null
instead -- i still don't like it very much because IMO it's confusing to work withnull
when explicitly trying to go the extra mile to work funtional style.So what I do is I add a
.ToOption()
after the call toDoSomething()
. I'd rather expected it to be vice-versa: requiring an extra call like "ToNullable()" to have it return aTask<A?>
.Maybe there's a good reason for the current behavior and someone can shed some light on it? Always happy to learn :-)
Beta Was this translation helpful? Give feedback.
All reactions