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

Add timed variant for IO[Unit] #4092

Open geirolz opened 1 week ago

geirolz commented 1 week ago

Hello folks! I'm not sure about the solution but I encountered this "problem" enough times to submit this PR. Basically when you want to use timed on an IO[Unit] you have to map the result to just keep the left side of the tuple. It would be nice to have a method to this directly within IO.

My proposal here introduces breaking changes, other more conservative solutions would be to use a dedicated name for this case such as:

Let me know what do you think! Thank :)