B => C val b2d : B => D val either : Either[A, B] either.leftMap(a2C) : Either[C, B] either.bimap(a2c, b2d) : Either[C, D] either.bifoldMap(a2c, b2c) : C
def findByIdInCache(id: Int): Option[A] val result: OptionT[Future, A] = for { url: String <- OptionT(getFromRedis(“key”)) id : Int <- OptionT.liftF(getViaHttp(url)) a : A <- OptionT.fromOption(findByIdInCache(id)) } yield a result.value // Future[Option[A]]
def findByIdInCache(id: Int): Option[A] val result: OptionT[Future, A] = for { url: String <- OptionT(getFromRedis(“key”)) id : Int <- OptionT.liftF(getViaHttp(url)) a : A <- OptionT.fromOption(findByIdInCache(id)) } yield a result.value // Future[Option[A]] 0QUJPO5ͷؔΛͬͯɺ શ෦0QUJPO5<'VUVSF ">ܕʹม
def findByIdInCache(id: Int): Option[A] val result: OptionT[Future, A] = for { url: String <- OptionT(getFromRedis(“key”)) id : Int <- OptionT.liftF(getViaHttp(url)) a : A <- OptionT.fromOption(findByIdInCache(id)) } yield a result.value // Future[Option[A]] ࠷ޙʹWBMVFؔͰ 'VUVSF<0QUJPO<">ʹ͢