package wow.doge.mygame.executors import cats.effect.Resource import monix.bio.IO import monix.bio.Task import monix.bio.UIO import monix.execution.Scheduler trait ExecutorsModule { val schedulers = Schedulers() val acquire: UIO[Either[Error, Int]] = IO.pure(1).onErrorHandleWith(_ => IO.raiseError(Error)).attempt // : Resource[IO[Error, Unit], Unit] val res = Resource.make(acquire)(_ => IO.unit) val x: Task[Either[Error, Unit]] = res.use { case Right(value) => Task(Right(println(s"got $value"))) case Left(value) => Task(Left(value)) } val z = x.onErrorHandleWith(ex => UIO(Right(ex.printStackTrace()))) val y: IO[Error, Unit] = z >> x.hideErrors.rethrow val jMESchedulerResource = Resource.make( Task( Scheduler .singleThread(name = "JME-Application-Thread", daemonic = false) ) )(e => Task(e.shutdown())) } sealed trait Error case object Error extends Error