我无法使用 cats 1.0.1 将 EitherT 列表转换为 EitherT 列表:
import cats.implicits._
val list: List[EitherT[Future, String, Int]] = List(1.pure, 2.pure)
val eitherOfList : EitherT[Future, String, List[Int]] = list.sequence
错误是:Nothing[List[Nothing]] 类型的表达式不符合预期类型 EitherT[Future, String, List[Int]]
最佳答案
遗憾的是,scala 类型推断并不是那么好,因此在使用 pure
语法时,您必须对代码进行注释。
type Stack[A] = EitherT[Future, String, A]
val list: List[Stack[Int]] = List(1.pure[Stack], 2.pure[Stack])
val eitherOfList: Stack[List[Int]] = list.sequence
关于scala - List[EitherT[Future, A, B]] 到 EitherT[Future, A, List[B]] 与猫,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48359344/