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.
|
|
package wow.doge.mygame
import cats.data.Reader import monix.bio.UIO import org.scalatest.funsuite.AnyFunSuite import monix.execution.Scheduler.Implicits.global
class ReaderTest extends AnyFunSuite {
// type IoReaderT[S, E, A] = ReaderT[UIO, S, Either[E, A]]
// val IoReaderT = ReaderT
// val t =
// ReaderT[UIO, String, Either[Error, Unit]](s => UIO.unit.attempt)
// .run("s")
// .rethrow
// val r: IoReaderT[String, Error, Unit] = IoReaderT(s => UIO.unit.attempt)
// val t2 = r.run("s").rethrow
// Kleisli[IO, String, Unit](s => IO.unit)
case class Environment(str: String, num: Int)
def fun1: Reader[String, UIO[Unit]] = Reader(str => UIO(println(str))) def fun2: Reader[Int, UIO[Unit]] = Reader(num => UIO(println(num)))
def total: Reader[Environment, UIO[Unit]] = for { x <- fun1.local[Environment](_.str) y <- fun2.local[Environment](_.num) } yield UIO.parSequence(List(x, y)).void
val io: UIO[Unit] = total.run(Environment("hello", 50))
test("runTest") { io.runSyncUnsafe() }
}
|