簡體   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]]?

我試過了:

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)

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM