【发布时间】:2013-06-04 13:21:09
【问题描述】:
不知道是否可以使用 Scalaz 7 编写类似的东西。我试图用代码块中的 cmets 来表达自己。
def validate1(p: String) = ValidationNel[String, Value] = ...
def validate2(p: String) = ValidationNel[String, Value] = ...
validateCombination(p1: String, p2: String) = {
// I would like to write something like
(validate1(p1) |@| validate2(p2)) { (v1, v1) =>
// And validate the combinations here and return successNel of failNel
}
}
def validate(p1: String, p2: String, p3: String) = {
(validateCombination(p1, p2) |@| validate1(p3)) { (v1, v2, v3) =>
// Notice the three parameters I want to have here
}
}
我最终会在 validateCombinations 中遇到不同类型的令人困惑的编译错误,或者我在 validate 函数中获得的应用函子只有 2 个参数,其中一个是 ValidationNel[...] 类型。
【问题讨论】:
标签: validation scala scalaz scalaz7