【发布时间】:2020-01-29 12:57:49
【问题描述】:
我有这个代码:
(for {
oldResult <- EitherT[Future, A, B](getById(id))
newResult <- EitherT.right(update(changeOldData(oldResult)))
} yield newResult).value
函数返回的地方
getById -> Future[Either[A, B]]
update -> Future[B]
changeOldData -> B
整个块应该返回:
Future[Either[A, B]]
在 IntelliJ 中,上面的代码没有任何抱怨,但是在编译时,我收到以下错误:
[error] found : B => cats.data.EitherT[scala.concurrent.Future,Nothing,B]
[error] required: B => cats.data.EitherT[scala.concurrent.Future,A,B]
[error] oldResult <- EitherT[Future, A, B](
我尝试不包含该类型,但我也遇到了同样的错误。 知道为什么吗?
【问题讨论】:
-
重要的是要注意 IntelliJ 的 Scala 演示编译器没有完整的功能。所以永远不要依赖 int。
标签: scala for-comprehension either