折叠EitherT [未来,可投掷,A]

时间:2017-08-28 13:48:06

标签: scala-cats

无法找出最适合将EitherT[Future, Throwable, A]折叠到Future[A]的惯用方式,其中Either的左侧将表示为失败的Future

2 个答案:

答案 0 :(得分:0)

简单的直接折叠是不是很好?

 foo.fold(Future.failed, Future.successful).flatten

答案 1 :(得分:0)

你可以使用fold并抛出你在左侧找到的Throwable

val foo: EitherT[Future, Throwable, A] = ???

import cats.instances.future._

foo.fold(throw _, identity)
相关问题