0
找不到最常用的方式来折EitherT[Future, Throwable, A]
到Future[A]
,其中Either
的左侧将表示为失败的Future
。Folding EitherT [Future,Throwable,A]
找不到最常用的方式来折EitherT[Future, Throwable, A]
到Future[A]
,其中Either
的左侧将表示为失败的Future
。Folding EitherT [Future,Throwable,A]
是一个简单的直线折叠不好吗?
foo.fold(Future.failed, Future.successful).flatten
你可以使用fold
扔你会发现无论Throwable
左侧
val foo: EitherT[Future, Throwable, A] = ???
import cats.instances.future._
foo.fold(throw _, identity)