Skip to content

Commit

Permalink
kyo.App improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Sep 24, 2023
1 parent 3c53284 commit af42ecc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion kyo-core/shared/src/main/scala/kyo/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import kyo.App.Effects
abstract class App {

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

def run(
args: List[String]
Expand All @@ -26,9 +26,20 @@ abstract class App {

object App {

private val defaultTimeout = Duration(System.getProperty("kyo.App.defaultTimeout", "1.minute"))

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

def run[T](timeout: Duration)(v: T > Effects): T =
IOs.run(runFiber(timeout)(v).map(_.block))

def run[T](v: T > Effects): T =
run(defaultTimeout)(v)

def runFiber[T](v: T > Effects): Fiber[T] > IOs =
runFiber(defaultTimeout)(v)

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) =
Expand Down

0 comments on commit af42ecc

Please sign in to comment.