What is the most popular optional / alternative monad? #1202
-
It seems more natural to use Am I missing something obvious? It seems to me Validation may not be as important as Option that gets an async version. I wonder how you guys use the monads. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
EitherAsync<A,B> is one that I find myself using a lot in my web apis in conjunction with linq. OptionAsync is another that I find myself using a lot as well. Validation is a new one for me, and I'm trying to do better about implementing it. I've known about it for a while, but it wasn't my main focus. |
Beta Was this translation helpful? Give feedback.
-
Always pick the Monad that provides the most limited set of guarantees required to accomplish the goal. If all you need is to detail that a function might not return a value, but will never fail, just use Option. If you want to outline that it can return 1 of 2 values, use Either. If you want to describe a function that returns 1 or many failures, use Validation. (This one should not come up as much) I would recommend looking through the API documentation, its all very good. IMHO, the async variants of Either, Options and Try are all a mistake. If you want an effect monad, use Eff and Aff. More than happy to talk to more specific cases and then talk through why a particular Monad might be better or worse. |
Beta Was this translation helpful? Give feedback.
Always pick the Monad that provides the most limited set of guarantees required to accomplish the goal.
If all you need is to detail that a function might not return a value, but will never fail, just use Option.
If you want to outline that it can return 1 of 2 values, use Either.
If you want to describe a function that returns 1 or many failures, use Validation. (This one should not come up as much)
I would recommend looking through the API documentation, its all very good.
IMHO, the async variants of Either, Options and Try are all a mistake. If you want an effect monad, use Eff and Aff.
More than happy to talk to more specific cases and then talk through why a particular Monad might be…