1

im quite new to cats-effects and im already loving and enjoying it :)

this is about fibers

as i saw that fibers can be cancelled im trying to see if its possible to have an IO with a list of fibers that, upon an error on any of the fibers, can cancel the rest of them (not sure if this can be done with the pure nature of IOs)

so having for example:

val job = IO("long processing")

val fibersIO: IO[NonEmptyList[String]] = NonEmptyList
  .of(job, job, job, job)
  .parTraverse(_.start)
  .flatMap(_.parTraverse(_.join))

would it be possible to implement something like this?

fibersIO.handleErrorWith { error =>
    // cancel contained fibers
}

any help/hint would be highly appreciated

0 Answers0