Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
928 B

4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
  1. package wow.doge.mygame.executors
  2. import cats.effect.Resource
  3. import monix.bio.IO
  4. import monix.bio.Task
  5. import monix.bio.UIO
  6. import monix.execution.Scheduler
  7. trait ExecutorsModule {
  8. val schedulers = Schedulers()
  9. val acquire: UIO[Either[Error, Int]] =
  10. IO.pure(1).onErrorHandleWith(_ => IO.raiseError(Error)).attempt
  11. // : Resource[IO[Error, Unit], Unit]
  12. val res = Resource.make(acquire)(_ => IO.unit)
  13. val x: Task[Either[Error, Unit]] = res.use {
  14. case Right(value) => Task(Right(println(s"got $value")))
  15. case Left(value) => Task(Left(value))
  16. }
  17. val z = x.onErrorHandleWith(ex => UIO(Right(ex.printStackTrace())))
  18. val y: IO[Error, Unit] = z >>
  19. x.hideErrors.rethrow
  20. val jMESchedulerResource = Resource.make(
  21. Task(
  22. Scheduler
  23. .singleThread(name = "JME-Application-Thread", daemonic = false)
  24. )
  25. )(e => Task(e.shutdown()))
  26. }
  27. sealed trait Error
  28. case object Error extends Error