我有以下代碼,我從這裏得到: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
您是否正在使用文章中提到的貓版本? –