Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cats Effect 1.0.0-RC #659

Merged
merged 12 commits into from
May 1, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CoevalShallowBindBenchmark {
if (i < size) Coeval.now(i + 1).flatMap(loop)
else Coeval.now(i)

Coeval.now(0).flatMap(loop).value()
Coeval.now(0).flatMap(loop).value
}

@Benchmark
Expand All @@ -60,6 +60,6 @@ class CoevalShallowBindBenchmark {
if (i < size) Coeval.eval(i + 1).flatMap(loop)
else Coeval.eval(i)

Coeval.eval(0).flatMap(loop).value()
Coeval.eval(0).flatMap(loop).value
}
}
49 changes: 44 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.typesafe.sbt.GitVersioning
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
import sbt.Keys.version
// For getting Scoverage out of the generated POM
import scala.xml.Elem
Expand All @@ -10,15 +12,15 @@ addCommandAlias("ci-js", ";clean ;coreJS/test:compile ;coreJS/test")
addCommandAlias("release", ";project monix ;+clean ;+package ;+publishSigned ;sonatypeReleaseAll")

val catsVersion = "1.1.0"
val catsEffectVersion = "0.10"
val catsEffectVersion = "1.0.0-RC"
val jcToolsVersion = "2.1.1"
val reactiveStreamsVersion = "1.0.2"
val scalaTestVersion = "3.0.4"
val minitestVersion = "2.1.1"

// The Monix version with which we must keep binary compatibility.
// https://github.com/typesafehub/migration-manager/wiki/Sbt-plugin
val monixSeries = "3.0.0"
val monixSeries = "3.0.0-RC1"

lazy val doNotPublishArtifact = Seq(
publishArtifact := false,
Expand Down Expand Up @@ -115,7 +117,10 @@ lazy val sharedSettings = warnUnusedImport ++ Seq(
// Turning off fatal warnings for ScalaDoc, otherwise we can't release.
scalacOptions in (Compile, doc) ~= (_ filterNot (_ == "-Xfatal-warnings")),

// ScalaDoc settings
// For working with partially-applied types
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6" cross CrossVersion.binary),

// ScalaDoc settings
autoAPIMappings := true,
scalacOptions in ThisBuild ++= Seq(
// Note, this is used by the doc-source-url feature to determine the
Expand Down Expand Up @@ -282,7 +287,41 @@ lazy val cmdlineProfile =
sys.env.getOrElse("SBT_PROFILE", "")

def mimaSettings(projectName: String) = Seq(
// mimaPreviousArtifacts := Set("io.monix" %% projectName % monixSeries)
mimaPreviousArtifacts := Set("io.monix" %% projectName % monixSeries),
mimaBinaryIssueFilters ++= Seq(
// Breakage — changed Task#foreach signature
exclude[IncompatibleResultTypeProblem]("monix.eval.Task.foreach"),
// Breakage — extra implicit param
exclude[DirectMissingMethodProblem]("monix.eval.TaskInstancesLevel0.catsEffect"),
exclude[DirectMissingMethodProblem]("monix.eval.instances.CatsConcurrentEffectForTask.this"),
exclude[DirectMissingMethodProblem]("monix.eval.instances.CatsEffectForTask.this"),
// Breakage - TaskApp
exclude[IncompatibleResultTypeProblem]("monix.eval.TaskApp.options"),
exclude[IncompatibleResultTypeProblem]("monix.eval.TaskApp.scheduler"),
exclude[ReversedMissingMethodProblem]("monix.eval.TaskApp.options"),
exclude[ReversedMissingMethodProblem]("monix.eval.TaskApp.scheduler"),
// Internals ...
exclude[DirectMissingMethodProblem]("monix.eval.Task#MaterializeTask.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.Coeval#MaterializeCoeval.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.Coeval#AttemptCoeval.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.Task#AttemptTask.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.StackFrame.recover"),
exclude[ReversedMissingMethodProblem]("monix.eval.internal.StackFrame.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.StackFrame.errorHandler"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.StackFrame.fold"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.TaskBracket#ReleaseRecover.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.TaskBracket#ReleaseRecover.this"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.CoevalBracket#ReleaseRecover.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.CoevalBracket#ReleaseRecover.this"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.TaskBracket.apply"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.TaskEffect.runAsync"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.TaskEffect.runCancelable"),
exclude[MissingClassProblem]("monix.eval.internal.CoevalBracket$ReleaseFrame"),
exclude[MissingClassProblem]("monix.eval.internal.TaskBracket$ReleaseFrame"),
exclude[MissingClassProblem]("monix.eval.internal.StackFrame$Fold"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.StackFrame#ErrorHandler.recover"),
exclude[DirectMissingMethodProblem]("monix.eval.internal.CoevalBracket.apply")
)
)

def profile: Project ⇒ Project = pr => cmdlineProfile match {
Expand Down Expand Up @@ -419,7 +458,7 @@ lazy val benchmarksPrev = project.in(file("benchmarks/vprev"))
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.settings(
libraryDependencies += "io.monix" %% "monix-reactive" % "2.3.2"
libraryDependencies += "io.monix" %% "monix" % "3.0.0-RC1"
)

lazy val benchmarksNext = project.in(file("benchmarks/vnext"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private[eval] object TaskRunSyncUnsafe {
case null => throw error
case bind =>
// Try/catch described as statement to prevent ObjectRef ;-)
try { current = bind.recover(error, scheduler) }
try { current = bind.recover(error) }
catch { case e if NonFatal(e) => current = Error(e) }
bFirst = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package monix.eval

import cats.{Applicative, Eq}
import cats.effect.IO
import cats.effect.laws.discipline.{ConcurrentTests, ConcurrentEffectTests}
import cats.effect.laws.discipline._
import cats.kernel.laws.discipline.MonoidTests
import cats.laws.discipline.{ApplicativeTests, CoflatMapTests, ParallelTests}
import cats.{Applicative, Eq}
import monix.eval.instances.CatsParallelForTask
import monix.execution.{Scheduler, UncaughtExceptionReporter}

Expand All @@ -36,27 +36,39 @@ object TypeClassLawsForTaskRunSyncUnsafeSuite extends monix.execution.BaseLawsSu
with ArbitraryInstancesBase {

implicit val sc = Scheduler(global, UncaughtExceptionReporter(_ => ()))

implicit val ap: Applicative[Task.Par] = CatsParallelForTask.applicative

val timeout = {
if (System.getenv("TRAVIS") == "true" || System.getenv("CI") == "true")
5.minutes
else
10.seconds
}

implicit val params = Parameters.default.copy(
// Disabling non-terminating tests (that test equivalence with Task.never)
// because they'd behave really badly with an Eq[Task] that depends on
// blocking threads
allowNonTerminationLaws = false)

implicit def equalityTask[A](implicit A: Eq[A]): Eq[Task[A]] =
Eq.instance { (a, b) =>
val ta = Try(a.runSyncUnsafe(5.minutes))
val tb = Try(b.runSyncUnsafe(5.minutes))
val ta = Try(a.runSyncUnsafe(timeout))
val tb = Try(b.runSyncUnsafe(timeout))
equalityTry[A].eqv(ta, tb)
}

implicit def equalityTaskPar[A](implicit A: Eq[A]): Eq[Task.Par[A]] =
Eq.instance { (a, b) =>
import Task.Par.unwrap
val ta = Try(unwrap(a).runSyncUnsafe(5.minutes))
val tb = Try(unwrap(b).runSyncUnsafe(5.minutes))
val ta = Try(unwrap(a).runSyncUnsafe(timeout))
val tb = Try(unwrap(b).runSyncUnsafe(timeout))
equalityTry[A].eqv(ta, tb)
}

implicit def equalityIO[A](implicit A: Eq[A]): Eq[IO[A]] =
Eq.instance { (a, b) =>
val ta = Try(a.unsafeRunSync())
val ta = Try(a.unsafeRunSync())
val tb = Try(b.unsafeRunSync())
equalityTry[A].eqv(ta, tb)
}
Expand Down
2 changes: 1 addition & 1 deletion monix-eval/shared/src/main/scala/monix/eval/Callback.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class Callback[-A] extends Listener[A] with (Try[A] => Unit) {
}

final def apply(result: Coeval[A]): Unit =
result.run match {
result.run() match {
case Coeval.Now(a) => onSuccess(a)
case Coeval.Error(e) => onError(e)
}
Expand Down
Loading