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

feature: Add clockForKleisli and sleepForKleisli #1242

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

geny200
Copy link
Contributor

@geny200 geny200 commented Apr 16, 2024

Hi, I suggest to add same functionality from cats for effects, so I opened a small pull request to demonstrate what I propose. If it's ok, then in the new PR I'll do it for all transformers and all effects.

Here is an example with a demonstration of the problem: In the first case, with cats everything is fine; in the second case, the ide says that everything is fine, but we get a compilation error.

  import cats.effect.{Clock => CatsClock}

  // Ok
  def catsClock[F[_]: Monad: CatsClock]: F[FiniteDuration] = {
    val clock = CatsClock[ReaderT[F, String, *]]
    clock.realTime.run("str")
  }

  import tofu.time.{Clock => TofuClock}
  
  // Error `could not find implicit value for parameter e: tofu.time.Clock[[╬│$1$]cats.data.Kleisli[F,String,╬│$1$]]`
  def tofuClock[F[_]: Monad: TofuClock]: F[Long] = {
    val clock = TofuClock[ReaderT[F, String, *]]
    clock.realTime(SECONDS).run("str")
  }

Коновалов Евгений Николаевич added 2 commits April 17, 2024 22:23
@dos65
Copy link
Collaborator

dos65 commented Apr 17, 2024

Thx for contribution!

If it's ok, then in the new PR I'll do it for all transformers and all effects.

Yeah. I think it's a good idea to provide instances for transfomers as CE does.

@dos65 dos65 merged commit a972f14 into tofu-tf:master Apr 17, 2024
9 checks passed
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.

None yet

2 participants