如何重构此代码以使用猫EitherT,ReaderT(?)和Future,这样我就可以摆脱嵌套并以for-comprehension样式编写它?
import scala.concurrent.Future
trait Foo[A, B, C, D, E] {
def bar(f: A => Future[B]): Future[B]
def baz: Future[Either[E, Future[C]]]
def qux(f: C => B)(a: A): B
def quz(e: E): Future[B]
def corge(c: C): B
def quux: Future[B] =
bar { a =>
baz flatMap {
case Left(e) => quz(e)
case Right(x) => x map { _ =>
qux(c => corge(c))(a)
}
}
}
}