Skip to content

Commit

Permalink
Downgrade to ApplicativeError
Browse files Browse the repository at this point in the history
  • Loading branch information
geirolz committed Jul 20, 2024
1 parent 3093d23 commit 3a98b5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shared/src/main/scala/mouse/anyf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package mouse

import cats.data.EitherT
import cats.data.OptionT
import cats.{Functor, MonadError, ~>}
import cats.{ApplicativeError, Functor, MonadError, ~>}

trait AnyFSyntax {
implicit final def anyfSyntaxMouse[F[_], A](fa: F[A]): AnyFOps[F, A] = new AnyFOps(fa)
Expand All @@ -48,13 +48,13 @@ final class AnyFOps[F[_], A](private val fa: F[A]) extends AnyVal {
def liftOptionT(implicit F: Functor[F]): OptionT[F, A] =
OptionT.liftF(fa)

// monadError error
def recoverAsLeft[E, L](pf: PartialFunction[E, L])(implicit F: MonadError[F, E]): F[Either[L, A]] =
// applicativeError
def recoverAsLeft[E, L](pf: PartialFunction[E, L])(implicit F: ApplicativeError[F, E]): F[Either[L, A]] =
recoverEither(pf.andThen(Left(_)))

def recoverAsRight[E](pf: PartialFunction[E, A])(implicit F: MonadError[F, E]): F[Either[Nothing, A]] =
def recoverAsRight[E](pf: PartialFunction[E, A])(implicit F: ApplicativeError[F, E]): F[Either[Nothing, A]] =
recoverEither(pf.andThen(Right(_)))

def recoverEither[E, L](pf: PartialFunction[E, Either[L, A]])(implicit F: MonadError[F, E]): F[Either[L, A]] =
def recoverEither[E, L](pf: PartialFunction[E, Either[L, A]])(implicit F: ApplicativeError[F, E]): F[Either[L, A]] =
F.recover(mapAsRight[L])(pf)
}

0 comments on commit 3a98b5d

Please sign in to comment.