【发布时间】:2018-03-14 00:57:05
【问题描述】:
我正在尝试使用 EitherT 实现以下目标:
def op1 : EitherT[Future, String, Int] = ???
def op2 : EitherT[Future, String, Int] = ???
for {
value1 <- op1
if value1 > 20
value2 <- op2
} yield value2
但我收到此错误:could not find implicit value for parameter ...
期望的行为是当 op1 的返回值不符合 if 条件时,返回 EitherT(Future.successful("Failed Validation".left[Int])),我该如何实现?
【问题讨论】:
-
你的意思是
def op1: EitherT[Future, String, Int] = ????
标签: scala concurrency monads scalaz monad-transformers