Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timed variant for IO[Unit] #4092

Open
wants to merge 1 commit into
base: series/3.x
Choose a base branch
from

Conversation

geirolz
Copy link

@geirolz geirolz commented Jun 26, 2024

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:

  • timed_
  • timedIgnore (with or without and )
  • timedL or timedR it depends on which side you see it
  • timedOnly

Let me know what do you think!
Thank :)

@ybasket
Copy link
Contributor

ybasket commented Jul 15, 2024

There's functor syntax in cats.syntax.all that lets you write myUnitIO.timed._1F to achieve the same, would that work for you? I'm no maintainer and this is no direct opinion on the PR, just wondered whether you are aware as it's syntactically very close to what you suggest.

Scastie example: https://scastie.scala-lang.org/5LQicwTuSf2e2Fkrds2qvw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants