[CE3] Kleisli Stack safety
See original GitHub issueThis 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:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ronanM Thanks for reporting and for the reproduction. I have a fix incoming.
I have a fix for
parTraverse
, I’ll open a PR later.