-
-
Notifications
You must be signed in to change notification settings - Fork 565
Closed
Description
I'm seeing FS2's parEvalMap dropping logs emitted by WriterT[IO.., while the sequential cousin evalMap retains them, as does a "desugared" Writer using parEvalMap.
Since parEvalMap is written in terms of Concurrent this hints at a potential problem in the WriterT instance, although I was not able to spot a problem from a visual inspection.
import fs2.*
import cats.*
import cats.syntax.all.*
import cats.data.*
import cats.effect.*
import cats.effect.implicits.*
object ConcurrentWriterTTest extends IOApp.Simple:
def tell(s: String): WriterT[IO, Chain[String], Unit] = WriterT.tell(Chain(s))
val run = Stream(1)
.parEvalMap(Int.MaxValue): _ =>
tell("loglog")
.compile.drain.written.flatMap(IO.println) //output: Chain()
object SequentialWriterTTest extends IOApp.Simple:
def tell(s: String): WriterT[IO, Chain[String], Unit] = WriterT.tell(Chain(s))
val run = Stream(1)
.evalMap: _ =>
tell("loglog")
.compile.drain.written.flatMap(IO.println) //output: Chain(loglog)
object ConcurrentWriterDesugaredTest extends IOApp.Simple:
def tell(s: String): IO[(Unit, Chain[String])] = IO.pure(() -> Chain(s))
val run = Stream(1)
.parEvalMap(Int.MaxValue): _ =>
tell("loglog")
.compile.toList.map(_.map(_._2)).flatMap(IO.println) //output: List(Chain(loglog))
Cats Effect 3.5.1 and FS2 3.7.0
Metadata
Metadata
Assignees
Labels
No labels