使用Scalaz ValidationNel,我有以下嵌套的Validations,我试图压扁:
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] = //...
使用sbt进行编译时,我得到:
[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) =>
^
我正在使用scala 2.10.0和scalaz 7.1.1
我做错了什么?