Before we start talking about monad transformers, let’s talk about why we may need them.
Let’s say we define the following classes and functions in this contrived example:
case class User(name : String) extends AnyVal case class Order(order : String) extends AnyVal case class DeliveryDetails(detail : String) extends AnyVal def getUser(name : String) : Future[Option[User]] = ??? def getOrder(user : User) : Future[Option[Order]] = ??? def getDeliveryDetails(order : Order) : Future[Option[DeliveryDetails]] = ???
If we want to get the delivery details of a particular user, we can easily do this via a for-comprehension:
Continue reading “Monad Transformers”