简体   繁体   English

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

[英]Scala Cats: How do I convert a List[ValidatedNel[E, A]] to Ior[NonEmptyList[E], List[A]]?

I tried: 我试过了:

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

I get: 我得到:

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

I then tried something like this: 然后我尝试了这样的事情:

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

Now I got: 现在我得到:

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

如@Toxaris所述, -Ypartial-unification需要打开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM