This module defines the HFiaR monad and all the actions you can perform in it
- data HFiaRT m a
- play :: Monad m => HFiaRT m a -> m Game
- eval :: Monad m => HFiaRT m a -> m a
- type HFiaR = HFiaRT IO
- justPlay :: HFiaR a -> IO Game
- justEval :: HFiaR a -> IO a
- data Game
- = OnCourse {
- gamePlayer :: Player
- gameBoard :: [[Tile]]
- | Ended {
- gameResult :: HFiaRResult
- gameBoard :: [[Tile]]
- = OnCourse {
- data Player = Pl {}
- data Tile
- data HFiaRError
- = GameEnded
- | GameNotEnded
- | InvalidColumn
- | FullColumn
- data HFiaRResult
- dropIn :: Monad m => Int -> HFiaRT m (Either HFiaRError ())
- tryDropIn :: Monad m => [Int] -> HFiaRT m (Either HFiaRError Game)
- player :: Monad m => HFiaRT m (Either HFiaRError Player)
- board :: Monad m => HFiaRT m [[Tile]]
- result :: Monad m => HFiaRT m (Either HFiaRError HFiaRResult)
MonadTrans controls
Generic HFiaRT type
play :: Monad m => HFiaRT m a -> m GameSource
Starts a game, run the HFiaRT actions and returns the game wrapped up in the m monad
eval :: Monad m => HFiaRT m a -> m aSource
Starts a game, run the HFiaRT actions and returns the result of the last one wrapped up in the m monad
Monad controls
justEval :: HFiaR a -> IO aSource
Starts a game, run the HFiaRT actions and returns the result of the last one
Types
Game description
OnCourse | |
| |
Ended | |
|
Posible players (each one with his tile colour)
data HFiaRError Source
Posible errors in the HFiaR Monad
data HFiaRResult Source
Posible results for the game
Actions
Drop a tile in a column
tryDropIn :: Monad m => [Int] -> HFiaRT m (Either HFiaRError Game)Source
Try (i.e. without actually doing it, returns the result of) dropping a tile in a column
player :: Monad m => HFiaRT m (Either HFiaRError Player)Source
Player who's supposed to play the next tile
result :: Monad m => HFiaRT m (Either HFiaRError HFiaRResult)Source
If the game ended, returns the result of it