Skip to content

Commit

Permalink
Remove calls to PartialFunction.apply, deprecated in 2.12.5 (#2188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alistair-Johnson authored and kailuowang committed Mar 12, 2018
1 parent 23e0a72 commit 6b01eda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions laws/src/main/scala/cats/laws/ApplicativeErrorLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ trait ApplicativeErrorLaws[F[_], E] extends ApplicativeLaws[F] {
F.attempt(F.pure(a)) <-> F.pure(Right(a))

def handleErrorWithConsistentWithRecoverWith[A](fa: F[A], f: E => F[A]): IsEq[F[A]] =
F.handleErrorWith(fa)(f) <-> F.recoverWith(fa)(PartialFunction(f))
F.handleErrorWith(fa)(f) <-> F.recoverWith(fa) { case x => f(x) }

def handleErrorConsistentWithRecover[A](fa: F[A], f: E => A): IsEq[F[A]] =
F.handleError(fa)(f) <-> F.recover(fa)(PartialFunction(f))
F.handleError(fa)(f) <-> F.recover(fa) { case x => f(x) }

def recoverConsistentWithRecoverWith[A](fa: F[A], pf: PartialFunction[E, A]): IsEq[F[A]] =
F.recover(fa)(pf) <-> F.recoverWith(fa)(pf andThen F.pure)
Expand All @@ -41,7 +41,7 @@ trait ApplicativeErrorLaws[F[_], E] extends ApplicativeLaws[F] {
F.attempt(F.fromEither(eab)) <-> F.pure(eab)

def onErrorPure[A](a: A, f: E => F[Unit]): IsEq[F[A]] =
F.onError(F.pure(a))(PartialFunction(f)) <-> F.pure(a)
F.onError(F.pure(a)) { case x => f(x) } <-> F.pure(a)

def onErrorRaise[A](fa: F[A], e: E, fb: F[Unit]): IsEq[F[A]] =
F.onError(F.raiseError[A](e)){case err => fb} <-> F.map2(fb, F.raiseError[A](e))((_, b) => b)
Expand Down
4 changes: 2 additions & 2 deletions laws/src/main/scala/cats/laws/MonadErrorLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ trait MonadErrorLaws[F[_], E] extends ApplicativeErrorLaws[F, E] with MonadLaws[
F.ensureOr(fa)(e)(p) <-> F.flatMap(fa)(a => if (p(a)) F.pure(a) else F.raiseError(e(a)))

def adaptErrorPure[A](a: A, f: E => E): IsEq[F[A]] =
F.adaptError(F.pure(a))(PartialFunction(f)) <-> F.pure(a)
F.adaptError(F.pure(a)) { case x => f(x) } <-> F.pure(a)

def adaptErrorRaise[A](e: E, f: E => E): IsEq[F[A]] =
F.adaptError(F.raiseError[A](e))(PartialFunction(f)) <-> F.raiseError(f(e))
F.adaptError(F.raiseError[A](e)) { case x => f(x) } <-> F.raiseError(f(e))

def rethrowAttempt[A](fa: F[A]): IsEq[F[A]] =
F.rethrow(F.attempt(fa)) <-> fa
Expand Down

0 comments on commit 6b01eda

Please sign in to comment.