Scala猫:如何将List [ValidatedNel [E,A]]转换为Ior [NonEmptyList [E],List [A]]?

时间:2018-12-11 20:40:13

标签: scala functional-programming scala-cats

我尝试过:

def convert[E, A](in: List[ValidatedNel[E, A]]): Ior[NonEmptyList[E], List[A]] =
    in.separate

我得到:

could not find implicit value for parameter G: cats.Bifoldable[cats.data.ValidatedNel]
[error]     in.separate

然后我尝试了这样的事情:

  def convert[E, A](in: List[ValidatedNel[E, A]]): Ior[NonEmptyList[E], List[A]] =
    in.traverse(_.toIor)

现在我得到了:

 could not find implicit value for evidence parameter of type cats.Applicative[G]
[error]     in.traverse(_.toIor)

1 个答案:

答案 0 :(得分:0)

如@Toxaris所述,-Ypartial-unification需要启用