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.

37 lines
1.0 KiB

3 years ago
  1. package wow.doge.mygame
  2. import cats.data.Reader
  3. import monix.bio.UIO
  4. import org.scalatest.funsuite.AnyFunSuite
  5. import monix.execution.Scheduler.Implicits.global
  6. class ReaderTest extends AnyFunSuite {
  7. // type IoReaderT[S, E, A] = ReaderT[UIO, S, Either[E, A]]
  8. // val IoReaderT = ReaderT
  9. // val t =
  10. // ReaderT[UIO, String, Either[Error, Unit]](s => UIO.unit.attempt)
  11. // .run("s")
  12. // .rethrow
  13. // val r: IoReaderT[String, Error, Unit] = IoReaderT(s => UIO.unit.attempt)
  14. // val t2 = r.run("s").rethrow
  15. // Kleisli[IO, String, Unit](s => IO.unit)
  16. case class Environment(str: String, num: Int)
  17. def fun1: Reader[String, UIO[Unit]] = Reader(str => UIO(println(str)))
  18. def fun2: Reader[Int, UIO[Unit]] = Reader(num => UIO(println(num)))
  19. def total: Reader[Environment, UIO[Unit]] =
  20. for {
  21. x <- fun1.local[Environment](_.str)
  22. y <- fun2.local[Environment](_.num)
  23. } yield UIO.parSequence(List(x, y)).void
  24. val io: UIO[Unit] = total.run(Environment("hello", 50))
  25. test("runTest") {
  26. io.runSyncUnsafe()
  27. }
  28. }