hfiar-1.2.0: Four in a Row in Haskell!!

HFiaR

Contents

Description

This module defines the HFiaR monad and all the actions you can perform in it

Synopsis

MonadTrans controls

data HFiaRT m a Source

Generic HFiaRT type

Instances

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

type HFiaR = HFiaRT MaybeSource

Basic HFiaR type - ready to just play HFiaR actions

justPlay :: HFiaR a -> GameSource

Starts a game, run the HFiaRT actions and returns the game

justEval :: HFiaR a -> aSource

Starts a game, run the HFiaRT actions and returns the result of the last one

Types

data Game Source

Game description

Instances

data Player Source

Posible players (each one with his tile colour)

Constructors

Pl 

Fields

tiles :: Tile
 

Instances

data Tile Source

Posible tiles (just green or red ones)

Constructors

Red 
Green 

Instances

data HFiaRError Source

Posible errors in the HFiaR Monad

data HFiaRResult Source

Posible results for the game

Constructors

Tie 
WonBy Player 

Actions

dropInSource

Arguments

:: Monad m 
=> Int

Column number

-> HFiaRT m (Either HFiaRError ()) 

Drop a tile in a column

player :: Monad m => HFiaRT m (Either HFiaRError Player)Source

Player who's supposed to play the next tile

board :: Monad m => HFiaRT m [[Tile]]Source

Current board distribution

result :: Monad m => HFiaRT m (Either HFiaRError HFiaRResult)Source

If the game ended, returns the result of it