Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.39 KB | None | 0 0
  1. +  implicit class RecoveringFutureEitherT[F[_], A, B](underlying: EitherT[F, A, B])(
  2. +    implicit me: MonadError[F, Throwable]) {
  3. +
  4. +    type MyEitherT[BB] = EitherT[F, A, BB]
  5. +
  6. +    def recoverF(pf: PartialFunction[Throwable, A]): EitherT[F, A, B] =
  7. +      MonadError[MyEitherT, Throwable].recoverWith(underlying) {
  8. +        case th => EitherT.fromEither[F](pf(th).asLeft[B])
  9. +      }
  10. +  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement