Michael
Michael

Reputation: 42100

Either, Try, and Validation in Scala

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.

What would you suggest ? Should I write this Result type by myself ?

Upvotes: 7

Views: 898

Answers (1)

Travis Brown
Travis Brown

Reputation: 139058

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.).

Upvotes: 8

Related Questions