From 079230a5d45cdfcc30fc00af595e842883ad2047 Mon Sep 17 00:00:00 2001 From: markhibberd Date: Wed, 22 Jan 2014 09:34:30 +1100 Subject: [PATCH] Expose CursorOp for via pattern matching and fold. This is is not ideal, but fixes #79 with breaking compatability, will revisit for 6.1 --- project/build.scala | 19 +++++++++++++++---- project/plugins.sbt | 2 ++ src/main/scala/argonaut/CursorOp.scala | 13 +++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/project/build.scala b/project/build.scala index be0e906b..660f5889 100644 --- a/project/build.scala +++ b/project/build.scala @@ -4,6 +4,10 @@ import com.typesafe.sbt.pgp.PgpKeys._ import Tools.onVersion import sbtrelease.ReleasePlugin._ +import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings +import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact +import com.typesafe.tools.mima.plugin.MimaKeys.binaryIssueFilters + object build extends Build { type Sett = Project.Setting[_] @@ -11,9 +15,9 @@ object build extends Build { organization := "io.argonaut" ) - val scalaz = "org.scalaz" %% "scalaz-core" % "7.0.3" - val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.0" % "test" - val scalazScalaCheckBinding = "org.scalaz" %% "scalaz-scalacheck-binding" % "7.0.3" % "test" + val scalaz = "org.scalaz" %% "scalaz-core" % "7.0.5" + val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.1" % "test" + val scalazScalaCheckBinding = "org.scalaz" %% "scalaz-scalacheck-binding" % "7.0.5" % "test" val specs2_1_12_4_1 = "org.specs2" %% "specs2" % "1.12.4.1" % "test" val specs2_1_14 = "org.specs2" %% "specs2" % "1.14" % "test" val caliper = "com.google.caliper" % "caliper" % "0.5-rc1" @@ -24,7 +28,7 @@ object build extends Build { val argonaut = Project( id = "argonaut" , base = file(".") - , settings = base ++ ReplSettings.all ++ releaseSettings ++ PublishSettings.all ++ InfoSettings.all ++ Seq[Sett]( + , settings = base ++ ReplSettings.all ++ releaseSettings ++ PublishSettings.all ++ InfoSettings.all ++ mimaDefaultSettings ++ Seq[Sett]( name := "argonaut" , (sourceGenerators in Compile) <+= (sourceManaged in Compile) map Boilerplate.gen , libraryDependencies <++= onVersion( @@ -32,6 +36,13 @@ object build extends Build { , on292 = Seq(specs2_1_12_4_1) , on210 = Seq(specs2_1_14) ) + , previousArtifact <<= (organization, name, scalaBinaryVersion) { (o, n, sbv) => Some(o % (n + "_" + sbv) % "6.0.1") } + , binaryIssueFilters ++= { + import com.typesafe.tools.mima.core._ + import com.typesafe.tools.mima.core.ProblemFilters._ + Seq( + "argonaut.CursorOp.fold" + ) map exclude[MissingMethodProblem] } ) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index eaecbd8a..6dc2caaf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,3 +3,5 @@ addSbtPlugin(("com.typesafe.sbt" % "sbt-pgp" % "0.7").cross(CrossVersion.full)) addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0") addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7") + +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.4") diff --git a/src/main/scala/argonaut/CursorOp.scala b/src/main/scala/argonaut/CursorOp.scala index 45a83b26..ccebc948 100644 --- a/src/main/scala/argonaut/CursorOp.scala +++ b/src/main/scala/argonaut/CursorOp.scala @@ -3,6 +3,14 @@ package argonaut import scalaz._, Scalaz._ sealed trait CursorOp { + def fold[X](reattempt: => X, el: (CursorOpElement, Boolean) => X) = + this match { + case Reattempt => + reattempt + case El(op, success) => + el(op, success) + } + def isReattempt: Boolean = this == Reattempt @@ -21,8 +29,9 @@ sealed trait CursorOp { case El(_, s) => !s } } -private case object Reattempt extends CursorOp -private case class El(o: CursorOpElement, success: Boolean) extends CursorOp + +case object Reattempt extends CursorOp +case class El(o: CursorOpElement, success: Boolean) extends CursorOp object CursorOp extends CursorOps { def apply(o: CursorOpElement): CursorOp =