Skip to content

Commit

Permalink
pure KyoApp.runFiber
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Sep 22, 2023
1 parent 053807d commit 2ce3f17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kyo-chatgpt/jvm/src/main/scala/kyo/chatgpt/UI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ object UI extends App {
_ <- chan.put((message, enabledModes.toList, p))
r <- p.get
} yield r
}.block
}.map(_.block)
}
}

Expand Down
16 changes: 9 additions & 7 deletions kyo-core/shared/src/main/scala/kyo/KyoApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ import randoms._
import concurrent.fibers._
import concurrent.timers._
import scala.concurrent.duration.Duration
import kyo.KyoApp.Effects

abstract class KyoApp {

final def main(args: Array[String]): Unit =
IOs.run(KyoApp.runFiber(Duration.Inf)(run(args.toList)).block)
IOs.run(KyoApp.runFiber(Duration.Inf)(run(args.toList)).map(_.block))

def run(
args: List[String]
): Unit > (IOs with Fibers with Resources with Clocks with Consoles with Randoms with Timers with Aspects)
): Unit > Effects

}

object KyoApp {
def runFiber[T](timeout: Duration)(
v: T > (IOs with Fibers with Resources with Clocks with Consoles with Randoms with Timers with Aspects)
): Fiber[T] = {

type Effects =
IOs with Fibers with Resources with Clocks with Consoles with Randoms with Timers with Aspects

def runFiber[T](timeout: Duration)(v: T > Effects): Fiber[T] > IOs = {
val v1
: T > (IOs with Fibers with Resources with Clocks with Consoles with Timers with Aspects) =
Randoms.run(v)
Expand All @@ -38,7 +41,6 @@ object KyoApp {
val v6: T > (IOs with Fibers) = Timers.run(v5)
val v7: T > (IOs with Fibers with Timers) = Fibers.timeout(timeout)(v6)
val v8: T > (IOs with Fibers) = Timers.run(v6)
val v9: Fiber[T] > IOs = Fibers.run(IOs.runLazy(v8))
IOs.run(v9)
IOs(Fibers.run(IOs.runLazy(v8)))
}
}
2 changes: 1 addition & 1 deletion kyo-core/shared/src/test/scala/kyoTest/KyoTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class KyoTest extends AsyncFreeSpec with Assertions {
def run(
v: => Assertion > (IOs with Fibers with Resources with Clocks with Consoles with Randoms with Timers)
): Future[Assertion] = {
IOs.run(KyoApp.runFiber(timeout)(v).toFuture)
IOs.run(KyoApp.runFiber(timeout)(v).map(_.toFuture))
}

class Check[T, S](equals: Boolean) {
Expand Down

0 comments on commit 2ce3f17

Please sign in to comment.