-
-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
It would be nice to add to Handle methods that takes PartialFunction something like ApplicativeError has (recover and recoverWith). For all unmatched cases raise an exception with ApplicativeError, something like:
def handlePartially[A](fa: F[A])(pf: PartialFunction[E, A])(implicit ap: ApplicativeError[F, Throwable]): F[A] =
handleWith[A](fa)(e => pf.andThen(applicative.pure[A](_)).applyOrElse[E, F[A]](e, me => ap.raiseError(new MatchError(me))))
And one step further, it would be super awesome if it would be possible to do like:
some_code.handlePartiallyWith[NarrowError](_.asLeft[Unit].pure[F])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels