summaryrefslogtreecommitdiffstats
path: root/Game.hs
blob: ef760d7bc24e86ee20f5b1859055c6091bab4933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Game ( GameState(..)
            , Game
            , runGame
            ) where

import Level
import Tank

import Control.Monad
import Control.Monad.State


data GameState = GameState
    { level   :: !Level
    , tanks   :: ![Tank]
    } deriving (Show)


newtype Game a = Game (StateT GameState IO a)
    deriving (Monad, MonadIO, MonadState GameState)

runGame :: GameState -> Game a -> IO (a, GameState)
runGame st (Game a) = runStateT a st