Scalaz nested Validation: could not find implicit

2019-07-19 07:49发布

问题:

Playing with Scalaz ValidationNel, I have the following nested Validations that I am trying to flatten:

import scala.xml.{NodeSeq, Node, Elem}
import scalaz._
import Scalaz._

val duration: ValidationNel[String, Int] = // ...
val nodes: ValidationNel[String, NodeSeq] = // ...

val r: ValidationNel[String, List[MyType]] = 
         (duration |@| nodes) { (d, ns) =>
           val n: ValidationNel[String, List[MyType]] = 
                  ns.toList.traverse[({ type l[X] = ValidationNel[String, X] })#l, MyType](extractMyType(_, d))
           n
         }.flatMap(identity)
// ...

private def extractMyType(n: Node, d: Int): ValidationNel[String, MyType] = //...

When compiling with sbt, I get:

[error] MyClass.scala:xx: could not find implicit value for parameter F0: scalaz.Bind[scalaz.Unapply[scalaz.Apply,scalaz.ValidationNel[String,Int]]{type M[X] = scalaz.ValidationNel[String,X]; type A = Int}#M]
[error]         val r = (duration |@| nodes) { (d, ns) =>
                                             ^

I am using scala 2.10.0 and scalaz 7.1.1

What am I doing wrong?