【发布时间】:2020-12-23 04:50:00
【问题描述】:
scala 中的常规期货提供zip 运算符。当两者都成功并并行运行它们时,它将结合它们的值。
有两个EitherT[Future, _, _]时,猫是否有类似的东西。
val a: EitherT[Future, String, Int] = EitherT.right(10)
val b: EitherT[Future, String, Int] = EitherT.right(20)
val sum: EitherT[Future, String, Int] = for ((a, b) <- a zip b) yield a + b
当a 和b 都是Right 值时,我希望sum 是Right(30)。此外,与Future.zip 函数一样,两个future 应该并行运行:
【问题讨论】:
标签: scala scala-cats