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

Upgrade to cats-1.0.0-RC1 and more #80

Merged
merged 2 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ startYear in ThisBuild := Some(2017)

val CompileTime = config("CompileTime").hide

val CatsVersion = "1.0.0-MF"
val SimulacrumVersion = "0.10.0"
val CatsVersion = "1.0.0-RC1"
val SimulacrumVersion = "0.11.0"

val ScalaTestVersion = "3.0.1"
val ScalaCheckVersion = "1.13.4"
val DisciplineVersion = "0.7.3"
val ScalaTestVersion = "3.0.4"
val ScalaCheckVersion = "1.13.5"
val DisciplineVersion = "0.8"

addCommandAlias("ci", ";test ;mimaReportBinaryIssues; doc")
addCommandAlias("release", ";project root ;reload ;+publishSigned ;sonatypeReleaseAll")
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/cats/effect/Async.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private[effect] trait AsyncInstances {
protected def FF = F

def async[A](k: (Either[Throwable, A] => Unit) => Unit): EitherT[F, L, A] =
EitherT.liftT(F.async(k))
EitherT.liftF(F.async(k))
}

private[effect] trait OptionTAsync[F[_]]
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/cats/effect/LiftIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private[effect] trait LiftIOInstances {
private implicit def _FF = FF

override def liftIO[A](ioa: IO[A]): EitherT[F, L, A] =
EitherT.liftT(F.liftIO(ioa))
EitherT.liftF(F.liftIO(ioa))
}

private[effect] trait KleisliLiftIO[F[_], R] extends LiftIO[Kleisli[F, R, ?]] {
Expand Down
6 changes: 3 additions & 3 deletions core/shared/src/main/scala/cats/effect/Sync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package effect

import simulacrum._

import cats.data.{EitherT, OptionT, StateT, WriterT}
import cats.data.{EitherT, IndexedStateT, OptionT, StateT, WriterT}
import cats.effect.internals.NonFatal

/**
Expand Down Expand Up @@ -100,7 +100,7 @@ private[effect] trait SyncInstances {
EitherT(F.handleErrorWith(fa.value)(f.andThen(_.value)))

def raiseError[A](e: Throwable): EitherT[F, L, A] =
EitherT.liftT(F.raiseError(e))
EitherT.liftF(F.raiseError(e))

def flatMap[A, B](fa: EitherT[F, L, A])(f: A => EitherT[F, L, B]): EitherT[F, L, B] =
fa.flatMap(f)
Expand Down Expand Up @@ -152,7 +152,7 @@ private[effect] trait SyncInstances {

// overwriting the pre-existing one, since flatMap is guaranteed stack-safe
def tailRecM[A, B](a: A)(f: A => StateT[F, S, Either[A, B]]): StateT[F, S, B] =
StateT.catsDataMonadForStateT[F, S].tailRecM(a)(f)
IndexedStateT.catsDataMonadForIndexedStateT[F, S].tailRecM(a)(f)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not spent any time whatsoever considering whether the instances can be generalized to IndexedStateT. This is minimal to make it compile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine sticking with this for the time being. It seems likely that we'll be able to generalize a bit, but it'll take some looking.


def suspend[A](thunk: => StateT[F, S, A]): StateT[F, S, A] =
StateT.applyF(F.suspend(thunk.runF))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait AsyncLaws[F[_]] extends SyncLaws[F] {

val read: F[A] = F.delay(cur)

change >> change >> read <-> F.pure(f(f(a)))
change *> change *> read <-> F.pure(f(f(a)))
}

def propagateErrorsThroughBindAsync[A](t: Throwable) = {
Expand Down
8 changes: 4 additions & 4 deletions laws/shared/src/main/scala/cats/effect/laws/EffectLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ trait EffectLaws[F[_]] extends AsyncLaws[F] {
var result: Option[Either[Throwable, A]] = None
val read = IO { result.get }

F.runAsync(fa)(e => IO { result = Some(e) }) >> read <-> IO.pure(Right(a))
F.runAsync(fa)(e => IO { result = Some(e) }) *> read <-> IO.pure(Right(a))
}

def runAsyncRaiseErrorProducesLeftIO[A](e: Throwable) = {
val fa: F[A] = F.raiseError(e)
var result: Option[Either[Throwable, A]] = None
val read = IO { result.get }

F.runAsync(fa)(e => IO { result = Some(e) }) >> read <-> IO.pure(Left(e))
F.runAsync(fa)(e => IO { result = Some(e) }) *> read <-> IO.pure(Left(e))
}

def runAsyncIgnoresErrorInHandler[A](e: Throwable) = {
Expand All @@ -55,9 +55,9 @@ trait EffectLaws[F[_]] extends AsyncLaws[F] {
cb(Right(()))
}

val test = F.runAsync(double >> change) { _ => IO.unit }
val test = F.runAsync(double *> change) { _ => IO.unit }

test >> readResult <-> IO.pure(f(a))
test *> readResult <-> IO.pure(f(a))
}
}

Expand Down
2 changes: 1 addition & 1 deletion laws/shared/src/main/scala/cats/effect/laws/SyncLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ trait SyncLaws[F[_]] extends MonadErrorLaws[F, Throwable] {
val change = F delay { cur = f(cur) }
val read = F.delay(cur)

change >> change >> read <-> F.pure(f(f(a)))
change *> change *> read <-> F.pure(f(f(a)))
}

def propagateErrorsThroughBindSuspend[A](t: Throwable) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package discipline

import cats.data._
import cats.laws.discipline._
import cats.laws.discipline.CartesianTests.Isomorphisms
import cats.laws.discipline.SemigroupalTests.Isomorphisms

import org.scalacheck._, Prop.forAll

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package laws
package discipline

import cats.laws.discipline._
import cats.laws.discipline.CartesianTests.Isomorphisms
import cats.laws.discipline.SemigroupalTests.Isomorphisms

import org.scalacheck._, Prop.forAll

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package discipline

import cats.data._
import cats.laws.discipline._
import cats.laws.discipline.CartesianTests.Isomorphisms
import cats.laws.discipline.SemigroupalTests.Isomorphisms

import org.scalacheck._, Prop.forAll

Expand Down
4 changes: 2 additions & 2 deletions laws/shared/src/test/scala/cats/effect/IOTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger

import cats.effect.laws.discipline.EffectTests
import cats.implicits._
import cats.kernel.laws.GroupLaws
import cats.kernel.laws.discipline.MonoidTests
import cats.laws._
import cats.laws.discipline._
import org.scalacheck._
Expand All @@ -34,7 +34,7 @@ class IOTests extends BaseTestsSuite {
import Generators._

checkAllAsync("IO", implicit ec => EffectTests[IO].effect[Int, Int, Int])
checkAllAsync("IO", implicit ec => GroupLaws[IO[Int]].monoid)
checkAllAsync("IO", implicit ec => MonoidTests[IO[Int]].monoid)

test("defer evaluation until run") {
var run = false
Expand Down