Advertisement
Guest User

I-broke-it

a guest
Aug 22nd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.69 KB | None | 0 0
  1. # Julien's snippet
  2.  
  3. 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.
  4.  
  5. import monocle.syntax._
  6. import monocle.function._
  7. import monocle.std.vector._
  8.  
  9. (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
  10.  
  11. [info] Compiling 4 Scala sources to /Users/ryanandlyndsey/projects/scala-sandbox/target/scala-2.11/classes...
  12. [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:5: expected class or object definition
  13. [error] (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
  14. [error] ^
  15. [error] one error found
  16.  
  17.  
  18. # Julien's snippet in an Object
  19.  
  20. import monocle.syntax._
  21. import monocle.function._
  22. import monocle.std.vector._
  23.  
  24. object Foo {
  25.   val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
  26. }
  27.  
  28. [info] Compiling 4 Scala sources to /Users/ryanandlyndsey/projects/scala-sandbox/target/scala-2.11/classes...
  29. [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:6: value applyOptional is not a member of scala.collection.immutable.Vector[Int]
  30. [error]   val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
  31. [error]                            ^
  32. [error] /Users/ryanandlyndsey/projects/scala-sandbox/monocle.scala:6: not found: value index
  33. [error]   val z = (Vector(0,1,2,3) applyOptional index(1) modify(_ + 1))
  34. [error]                                          ^
  35. [error] two errors found
  36.  
  37.  
  38. # build.sbt, sbt v0.13
  39.  
  40. import sbt._
  41.  
  42. // BEGIN - Monacle
  43. resolvers += Resolver.sonatypeRepo("releases")
  44. resolvers += Resolver.sonatypeRepo("snapshots")
  45.  
  46. val monacleVersion = "1.2.2"     // or "1.3.0-SNAPSHOT"
  47.  
  48. libraryDependencies ++= Seq(
  49.   "com.github.julien-truffaut"  %%  "monocle-core"    % monacleVersion,
  50.   "com.github.julien-truffaut"  %%  "monocle-generic" % monacleVersion,
  51.   "com.github.julien-truffaut"  %%  "monocle-macro"   % monacleVersion,
  52.   "com.github.julien-truffaut"  %%  "monocle-state"   % monacleVersion,
  53.   "com.github.julien-truffaut"  %%  "monocle-refined" % monacleVersion,
  54.   "com.github.julien-truffaut"  %%  "monocle-law"     % monacleVersion % "test"
  55. )
  56.  
  57. // for @Lenses macro support
  58. scalacOptions ++= Seq("-language:higherKinds") // @Lens annotation requires higherKinded types; TODO is there a runtime cost for @Lens?
  59. addCompilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.full)
  60. // END - Monacle
  61.  
  62. lazy val root = (project in file(".")).
  63.   settings(
  64.     name := "hello",
  65.     version := "1.0",
  66.     scalaVersion := "2.11.8",
  67.     libraryDependencies ++= Seq(
  68.       "com.typesafe.akka" %% "akka-actor" % "2.4.9-RC2"
  69.       // exampleo of test-only dependency: "com.typesafe.akka" %% "akka-actor" % "2.4.9-RC2" % Test
  70.     )
  71.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement