Missing some functions in OptionAsync #1274
Unanswered
JosVroegindeweij
asked this question in
Q&A
Replies: 1 comment
-
You could try this approach instead: using
NOTE: This is using the Really you're trying to do the work of a validation monad rather than an either here. You might want to consider developing a more bespoke monad for your use-case, or use language-ext's |
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
-
Hello there,
Thanks for making this library, it made me get back into the functional programming world again, but university is so long ago :)
I'm trying to come up with an elegant solution for the following problem:
EitherAsync<Error, byte[]> GetDataX(Command cmd)
).OptionAsync<Error> ProcessDataX(byte[])
)When errors are encountered in step 1, we should early exit. When errors are encountered in step 2, we should not early exit. In the end, I want to end up with an
OptionAsync<Error>
, where in the error all errors are accumulated (either a single error if it got returned fromGetDataX
or a accumulated error if it happened in one or more ofProcessDataX
)I have managed to make the following work (as a simplified example), but I hope this is not the only way
A few things I dislike about this:
MainFunction
and theProcessDataX
functions return anEitherAsync<Error, Unit>
instead of anOptionAsync<Error>
. I've tried getting the same results with anOptionAsync<Error>
but there is no functionOptionAsync<A>.BiBind()
in the library and trying to write it myself outside of the library went horribly wrong :)Any help, considerations or pointers would be greatly appreciated!
Edit: I just noticed the title is not very descriptive of the rest of the story I just wrote. The title is about the lack of the
BiBind
andBiBindAsync
methods onOptionAsync
.Also, I just read the proposal for making the
OptionAsync
andEitherAsync
obsolete. How could I use theAff
as proposed there in this use case?Beta Was this translation helpful? Give feedback.
All reactions