Managing imports in Scalaz7

放肆的年华 提交于 2019-11-29 06:12:44

This blog post explains the package structure and imports a la carte in scalaz7 in detail: http://eed3si9n.com/learning-scalaz-day13

For your specific examples, for 3.failure[String] you'd need:

import scalaz.syntax.validation._

Validation already has a method ap:

scala> "hello".successNel[Int] ap ((s: String) => "x"+s).successNel[Int]
res1: scalaz.Validation[scalaz.NonEmptyList[Int],java.lang.String] = Success(xhello)

To get the <*> operator, you need this import:

import scalaz.syntax.applicative._

Then you can do:

"hello".successNel[Int] <*> ((s: String) => "x"+s).successNel[Int]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!