aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-01-02 10:00:35 -0800
committer3gg <3gg@shellblade.net>2025-01-02 10:00:35 -0800
commitba128de9313cb0fe4dc2a8e4d6054a4b93341f2b (patch)
treef4e9b0af1e16ed8a2d884897f5dea5a5b6625df9
parentae29688a6bcd05daf9154fb5792861723afdb1ed (diff)
Rename runSubGame -> runChildGame.
-rw-r--r--Spear/App.hs2
-rw-r--r--Spear/Game.hs10
-rw-r--r--Spear/Scene/Loader.hs2
3 files changed, 7 insertions, 7 deletions
diff --git a/Spear/App.hs b/Spear/App.hs
index 6e8f5f2..e85c46b 100644
--- a/Spear/App.hs
+++ b/Spear/App.hs
@@ -163,7 +163,7 @@ runApp app =
163 , appCustomState = gameState 163 , appCustomState = gameState
164 } 164 }
165 -- Run app. 165 -- Run app.
166 (result, endAppState) <- runSubGame appState $ do 166 (result, endAppState) <- runChildGame appState $ do
167 loop app window 167 loop app window
168 endApp app 168 endApp app
169 -- Shut down. 169 -- Shut down.
diff --git a/Spear/Game.hs b/Spear/Game.hs
index 0c8b963..ae986c8 100644
--- a/Spear/Game.hs
+++ b/Spear/Game.hs
@@ -22,7 +22,7 @@ module Spear.Game
22, catch 22, catch
23 -- * Running and IO 23 -- * Running and IO
24, runGame 24, runGame
25, runSubGame 25, runChildGame
26, runSiblingGame 26, runSiblingGame
27, eval 27, eval
28, exec 28, exec
@@ -106,18 +106,18 @@ assertMaybe (Just x) _ = return x
106runGame :: s -> Game s a -> IO (a, s) 106runGame :: s -> Game s a -> IO (a, s)
107runGame state game = runResourceT . runStateT (getGame game) $ state 107runGame state game = runResourceT . runStateT (getGame game) $ state
108 108
109-- | Run the given sub-game, unrolling the full monad stack and returning the 109-- | Run the given child game, unrolling the full monad stack and returning the
110-- game's result and its final state. 110-- game's result and its final state.
111-- 111--
112-- Like `runGame`, this frees any resources that are acquired by the sub-game. 112-- Like `runGame`, this frees any resources that are acquired by the sub-game.
113-- If you want to keep acquired resources, see `runSiblingGame` instead. 113-- If you want to keep acquired resources, see `runSiblingGame` instead.
114runSubGame :: s -> Game s a -> Game t (a, s) 114runChildGame :: s -> Game s a -> Game t (a, s)
115runSubGame state game = liftIO $ runGame state game 115runChildGame state game = liftIO $ runGame state game
116 116
117-- | Run the given sibling game, unrolling the state transformer but not the 117-- | Run the given sibling game, unrolling the state transformer but not the
118-- resource transformer. 118-- resource transformer.
119-- 119--
120-- Unlike `runSubGame`, any resources acquired by the sibling game are *not* 120-- Unlike `runChildGame`, any resources acquired by the sibling game are *not*
121-- released. 121-- released.
122runSiblingGame :: s -> Game s a -> Game t (a, s) 122runSiblingGame :: s -> Game s a -> Game t (a, s)
123runSiblingGame state game = Game . lift $ runStateT (getGame game) state 123runSiblingGame state game = Game . lift $ runStateT (getGame game) state
diff --git a/Spear/Scene/Loader.hs b/Spear/Scene/Loader.hs
index 5f96f8c..0593c77 100644
--- a/Spear/Scene/Loader.hs
+++ b/Spear/Scene/Loader.hs
@@ -58,7 +58,7 @@ validate _ = Nothing
58 58
59-- | Load the scene described by the given 'SceneGraph'. 59-- | Load the scene described by the given 'SceneGraph'.
60resourceMap :: SceneGraph -> Game s SceneResources 60resourceMap :: SceneGraph -> Game s SceneResources
61resourceMap g = exec runSubGame emptySceneResources (resourceMap' g) 61resourceMap g = exec runChildGame emptySceneResources (resourceMap' g)
62 62
63resourceMap' :: SceneGraph -> Loader () 63resourceMap' :: SceneGraph -> Loader ()
64resourceMap' node@(SceneLeaf nid props) = do 64resourceMap' node@(SceneLeaf nid props) = do