module Engine.App
( engineMain
, engineMainWith
) where
import RIO
import RIO.App (appMain)
import Engine.Run (runStack)
import Engine.Setup (setup)
import Engine.Types qualified as Engine
import Engine.Types.Options (Options(..), getOptions)
import Engine.Stage.Bootstrap.Setup qualified as Bootstrap
engineMain :: Engine.StackStage -> IO ()
engineMain :: StackStage -> IO ()
engineMain StackStage
initialStage = (() -> StackStage) -> StageSetupRIO () -> IO ()
forall a. (a -> StackStage) -> StageSetupRIO a -> IO ()
engineMainWith (\() -> StackStage
initialStage) (() -> StageSetupRIO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
engineMainWith :: (a -> Engine.StackStage) -> Engine.StageSetupRIO a -> IO ()
engineMainWith :: forall a. (a -> StackStage) -> StageSetupRIO a -> IO ()
engineMainWith a -> StackStage
handoff StageSetupRIO a
action =
IO Options
-> (Options -> Bool)
-> (Options
-> RIO SetupApp (GlobalHandles, Maybe SwapchainResources))
-> StageSetupRIO ()
-> IO ()
forall options env st.
IO options
-> (options -> Bool)
-> (options -> RIO SetupApp (env, st))
-> RIO (App env st) ()
-> IO ()
appMain IO Options
getOptions Options -> Bool
optionsVerbose Options -> RIO SetupApp (GlobalHandles, Maybe SwapchainResources)
forall env.
(HasLogFunc env, MonadResource (RIO env)) =>
Options -> RIO env (GlobalHandles, Maybe SwapchainResources)
setup (StageSetupRIO () -> IO ()) -> StageSetupRIO () -> IO ()
forall a b. (a -> b) -> a -> b
$ StageStack -> StageSetupRIO ()
runStack
[
(a -> StackStage) -> StageSetupRIO a -> StackStage
forall a. (a -> StackStage) -> StageSetupRIO a -> StackStage
Bootstrap.stackStage a -> StackStage
handoff StageSetupRIO a
action
]