question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CE3] Kleisli Stack safety

See original GitHub issue

This code is Ok with CE2, but fail with StackOverflowError in CE3.

import cats.effect.{ExitCode, IO, IOApp}
import cats.syntax.all._
import cats.data.Kleisli

object MainKleisli extends IOApp {

  override def run(args: List[String]): IO[ExitCode] = {
    val N = 10000
    var i = 0

    List.fill(N)(0).traverse_(_ => Kleisli.liftF(IO(i += 1))).run("Go...") *>
      IO(println(s"i: ${i}")) *>
      IO(assert(i === N, s"i: $i != $N")).as(ExitCode.Success)
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vasilmkdcommented, Jul 5, 2021

@ronanM Thanks for reporting and for the reproduction. I have a fix incoming.

0reactions
vasilmkdcommented, Jul 25, 2021

I have a fix for parTraverse, I’ll open a PR later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kliesli is not stack-safe on left-associated binds #1733 - GitHub
I think that safety (no runtime surprises) is a major argument for reformulating Kleisli to be stack-safe. I think that consistency with ...
Read more >
Understanding Comparative Benchmarks (Cats Effect 3 and ...
Finally, we will look at the performance of CE3 Resource versus ZIO , since resource-safe concurrency is such a shining strength of both...
Read more >
When should one use a Kleisli? - Stack Overflow
One needn't lean on the Kleisli construct to achieve this. So this cannot be the "primary" use case of a Kleisli IMO.
Read more >
scala-logger - Scaladex
This method has the advantage of being faster than Kleisli and it is stack safe. ⚠️ Every time you call createIOLocalContext , an...
Read more >
fsprojects/FSharpPlus - Gitter
Hi, do you plan to add stack safe version of free monad? current implementation of free's ... I seem unable to get >=>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found