> >Again, IMHO, while Option is an exceptionally useful type, when indicating errors at the "public API level" it proves to be insufficient.
> Agreed. Either, or even better, \/ (Scalaz either/disjunction) is much easier to work with and more expressive.
I, too, recommend using the Scalaz \/[0] Either type as it is "right leaning" and lends itself quite nicely to processing due to it being both a model of Bifunctor[1] (making handling either a success or failure situation quite clean) and contributing nicely to defining an EitherT monad transformer capable of abstracting both latency (the Future part) and errors (the \/ part).
For example, I often have the following defined in projects:
type FutureEither[+T] = EitherT[Future, DomainError, T]
Where "DomainError" is a top-level type representing an error encountered during processing.
All this adds up to being able to work with "happy path" logic, deferring error handling until it can be handled/reported and network request/response latency absorbed until it becomes an error (addressed as any other error would be).
> Agreed. Either, or even better, \/ (Scalaz either/disjunction) is much easier to work with and more expressive.
I, too, recommend using the Scalaz \/[0] Either type as it is "right leaning" and lends itself quite nicely to processing due to it being both a model of Bifunctor[1] (making handling either a success or failure situation quite clean) and contributing nicely to defining an EitherT monad transformer capable of abstracting both latency (the Future part) and errors (the \/ part).
For example, I often have the following defined in projects:
Where "DomainError" is a top-level type representing an error encountered during processing.All this adds up to being able to work with "happy path" logic, deferring error handling until it can be handled/reported and network request/response latency absorbed until it becomes an error (addressed as any other error would be).
0 - https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/...
1 - https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/...