From 7043b05a4088c7ccb77f820070e75411d3202141 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Tue, 19 Nov 2019 07:45:58 -0600 Subject: [PATCH] Add adaptError override to MonadError --- core/src/main/scala/cats/MonadError.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/scala/cats/MonadError.scala b/core/src/main/scala/cats/MonadError.scala index 11e14ef328..4a151c0b36 100644 --- a/core/src/main/scala/cats/MonadError.scala +++ b/core/src/main/scala/cats/MonadError.scala @@ -76,6 +76,9 @@ trait MonadError[F[_], E] extends ApplicativeError[F, E] with Monad[F] { */ def redeemWith[A, B](fa: F[A])(recover: E => F[B], bind: A => F[B]): F[B] = flatMap(attempt(fa))(_.fold(recover, bind)) + + override def adaptError[A](fa: F[A])(pf: PartialFunction[E, E]): F[A] = + recoverWith(fa)(pf.andThen(raiseError[A] _)) } object MonadError {