Skip to content

Commit

Permalink
Expose CursorOp for via pattern matching and fold.
Browse files Browse the repository at this point in the history
This is is not ideal, but fixes #79 with breaking compatability, will revisit for 6.1
  • Loading branch information
markhibberd committed Jan 21, 2014
1 parent 0a23bf8 commit 8c7d682
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
19 changes: 15 additions & 4 deletions project/build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ 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[_]

val base = Defaults.defaultSettings ++ ScalaSettings.all ++ Seq[Sett](
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"
Expand All @@ -24,14 +28,21 @@ 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(
all = Seq(scalaz, scalacheck, scalazScalaCheckBinding)
, 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] }
)
)

Expand Down
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
13 changes: 11 additions & 2 deletions src/main/scala/argonaut/CursorOp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 =
Expand Down

0 comments on commit 8c7d682

Please sign in to comment.