scalaz 7相当于来自scalaz 6的`<| * |>`
发布时间:2020-12-16 18:39:31 所属栏目:安全 来源:网络整理
导读:在 Nick Partridge’s presentation on deriving scalaz中,基于旧版本的scalaz,他使用函数引入了验证: def even(x: Int): Validation[NonEmptyList[String],Int] = if (x % 2 == 0) x.success else { s"not even: $x".wrapNel.failure } 然后他结合这个使用
在
Nick Partridge’s presentation on deriving scalaz中,基于旧版本的scalaz,他使用函数引入了验证:
def even(x: Int): Validation[NonEmptyList[String],Int] = if (x % 2 == 0) x.success else { s"not even: $x".wrapNel.failure } 然后他结合这个使用 even(1) <|*|> even(2) 应用测试并返回带有失败消息的验证.使用scalaz 7我得到了 scala> even(1) <|*|> even(2) <console>:18: error: value <|*|> is not a member of scalaz.Validation[scalaz.NonEmptyList[String],Int] even(1) <|*|> even(2) ^ 什么是scalaz 7相当于这个组合器? 解决方法
这现在称为元组,所以你可以写例如:
import scalaz._,Scalaz._ def even(x: Int): Validation[NonEmptyList[String],Int] = if (x % 2 == 0) x.success else s"not even: $x".failureNel val pair: ValidationNel[String,(Int,Int)] = even(1) tuple even(2) 不幸的是,我不确定是否有更好的方法来找出这种事情,而不是检查源的最后6.0标记,搜索,然后比较签名. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |