I am confused with Either
, Try
, and Validation
of scalaz
. None of them seems to do what I need. What I need is a simple monad Result[E, R]
where E
is an error type and R
is an result type.
Either
is not suitable because it is not a monad (but the projections are) and unbiased.Try
is not suitable since its error type is Throwable
and it is not exactly a monadValidation
is not a monad at all.What would you suggest ? Should I write this Result
type by myself ?
If you're willing to use Scalaz (and it sounds like you are), \/
(usually pronounced "disjunction") is exactly what you're looking for—a monadic, right-biased version of Either
.
It also includes lots of other nice stuff you don't get with the right projection of Either
in the standard library (1.right
syntax, combinators like +++
, converters from Validation
, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With