[server] Adjust TreeModule structure
This commit prepares a slighly more powerful TreeModule structure: Now, TreeModules can finish their execution, which should make some kinds of menus and transitions possible.
This commit is contained in:
parent
d08f858692
commit
220b5a3234
4 changed files with 26 additions and 18 deletions
|
|
@ -3,6 +3,7 @@
|
|||
module Forest.Util
|
||||
( findPrev
|
||||
, findNext
|
||||
, whileM
|
||||
, withThread
|
||||
, sendPacket
|
||||
, closeWithErrorMessage
|
||||
|
|
@ -25,6 +26,14 @@ findNext f as = snd <$> find (f . fst) (zip as $ tail as)
|
|||
withThread :: IO () -> IO () -> IO ()
|
||||
withThread thread main = withAsync thread $ const main
|
||||
|
||||
-- | Run a monadic action until it returns @False@ for the first time.
|
||||
whileM :: Monad m => m Bool -> m ()
|
||||
whileM f = do
|
||||
continue <- f
|
||||
if continue
|
||||
then whileM f
|
||||
else pure ()
|
||||
|
||||
sendPacket :: ToJSON a => WS.Connection -> a -> IO ()
|
||||
sendPacket conn packet = WS.sendTextData conn $ encode packet
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue