Monad transformers let you cut through nested monads (“stacks of monads”):
- Future[Either[A, Option[B]]]
- Future[Either[A, B]]
- Future[Option[A]]
Why you would want to do that:
- You do not need nested for-comprehensions
- Your code is cleaner and easier to maintain
- You look awesome doing it
Avoid:
- Returning monad transformers, instead return the original monads
Why:
- Let the client code decide what to do about the monad(s)
- Avoid importing cats everywhere
- Consumer choice (might prefer scalaz)
Code: