This repository has been archived on 2025-03-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
htanks/src/MainLoop.hs
2010-03-09 19:53:59 +01:00

31 lines
727 B
Haskell

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module MainLoop ( MainState(..)
, MainT(..)
, Main
, runMain
) where
import Game
import GLDriver
import Player
import Control.Monad.State
import Control.Monad.Trans
import Data.Time
data MainState = MainState
{ run :: !Bool
, driver :: !SomeDriver
, time :: !UTCTime
, players :: ![SomePlayer]
}
newtype MainT m a = MainT (StateT MainState m a)
deriving (Monad, MonadState MainState, MonadIO, MonadTrans)
type Main = MainT Game
runMain :: MainState -> Main a -> Game (a, MainState)
runMain st (MainT a) = runStateT a st