Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Julien's snippet
- N.B. this compiled the first time I pasted it, and now it doesn't. Have tried cleaning and running it in a new, empty sbt project.
- import monocle.syntax._
- import monocle.function._
- import monocle.std.vector._
- (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
- [info] Compiling 4 Scala sources to /Users/ryanandlyndsey/projects/scala-sandbox/target/scala-2.11/classes...
- [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:5: expected class or object definition
- [error] (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
- [error] ^
- [error] one error found
- # Julien's snippet in an Object
- import monocle.syntax._
- import monocle.function._
- import monocle.std.vector._
- object Foo {
- val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
- }
- [info] Compiling 4 Scala sources to /Users/ryanandlyndsey/projects/scala-sandbox/target/scala-2.11/classes...
- [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:6: value applyOptional is not a member of scala.collection.immutable.Vector[Int]
- [error] val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
- [error] ^
- [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:6: not found: value index
- [error] val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
- [error] ^
- [error] two errors found
- # build.sbt, sbt v0.13
- import sbt._
- // BEGIN - Monacle
- resolvers += Resolver.sonatypeRepo("releases")
- resolvers += Resolver.sonatypeRepo("snapshots")
- val monacleVersion = "1.2.2" // or "1.3.0-SNAPSHOT"
- libraryDependencies ++= Seq(
- "com.github.julien-truffaut" %% "monocle-core" % monacleVersion,
- "com.github.julien-truffaut" %% "monocle-generic" % monacleVersion,
- "com.github.julien-truffaut" %% "monocle-macro" % monacleVersion,
- "com.github.julien-truffaut" %% "monocle-state" % monacleVersion,
- "com.github.julien-truffaut" %% "monocle-refined" % monacleVersion,
- "com.github.julien-truffaut" %% "monocle-law" % monacleVersion % "test"
- )
- // for @Lenses macro support
- scalacOptions ++= Seq("-language:higherKinds") // @Lens annotation requires higherKinded types; TODO is there a runtime cost for @Lens?
- addCompilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.full)
- // END - Monacle
- lazy val root = (project in file(".")).
- settings(
- name := "hello",
- version := "1.0",
- scalaVersion := "2.11.8",
- libraryDependencies ++= Seq(
- "com.typesafe.akka" %% "akka-actor" % "2.4.9-RC2"
- // exampleo of test-only dependency: "com.typesafe.akka" %% "akka-actor" % "2.4.9-RC2" % Test
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement