typelevel / cats-effect

The pure asynchronous runtime for Scala
https://typelevel.org/cats-effect/
Apache License 2.0
1.99k stars 511 forks source link

IO.onError is inconsistent with ApplicativeError #4058

Open Jasper-M opened 2 months ago

Jasper-M commented 2 months ago

The onError that you get from ApplicativeError has this signature:

def onError[A](fa: F[A])(pf: PartialFunction[E, F[Unit]]): F[A]

While the "native" one in IO doesn't take a PartialFunction:

def onError(f: Throwable => IO[Unit]): IO[A]

That could lead to some surprises if you would rewrite a piece of code from tagless final to IO, or if you are just used to using the onError extension method in other code.

armanbilge commented 2 months ago

I think we can fix this one fairly source-compatibly.

borgben commented 1 month ago

Hey @armanbilge @Jasper-M I'd love to take this on, if you'd assign it to me.

djspiewak commented 1 month ago

Assigned!