我有以下代码,我从这里得到:http://underscore.io/blog/posts/2015/06/10/an-introduction-to-cats.html。猫无法解析符号| @ |
import cats.data.Xor
import cats.data.{Validated, Xor}
import cats.syntax.apply._ // For |@| syntax
import cats.std.list._
val v1: ValidatedR = valid(1)
val v2: ValidatedR = invalid(List("Accumulates this"))
val v3: ValidatedR = invalid(List("And this"))
(v1 |@| v2 |@| v3) map { _ + _ + _ }
但是,我越来越:
Cannot resolve symbol |@|
我build.sbt
:
val snapshots = "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
val algebraVersion = "0.2.0-SNAPSHOT"
val catsVersion = "0.1.0-SNAPSHOT"
val algebra = "org.spire-math" %% "algebra" % algebraVersion
val algebraStd = "org.spire-math" %% "algebra-std" % algebraVersion
val cats = "org.spire-math" %% "cats-core" % catsVersion
val catsStd = "org.spire-math" %% "cats-std" % catsVersion
scalaVersion := "2.11.6"
libraryDependencies ++=
Seq(
algebra, algebraStd,
cats, catsStd
)
resolvers += snapshots
还有什么,我应该是进口或者使用?
导入现在是'cats.syntax.cartesian._','List'实例现在可以通过'cats.instances.list._'导入。可能最简单的方法是使用'import cats.implicits._'。 –
当导入'cats.syntax.cartesian._'时,我得到'错误:(2,22)对象笛卡儿不是包cats.syntax'的成员 ^ – octavian
您是否正在使用文章中提到的猫版本? –