TicTacToe-0.0.1: A sub-project (exercise) for a functional programming course

Data.TicTacToe.GameResult

Contents

Description

A game result is one of

  • Player 1 wins
  • Player 2 wins
  • Neither player wins (draw)

Synopsis

Documentation

Reduction (fold)

gameResultSource

Arguments

:: (Player -> x)

If either of the players won.

-> x

If the game was a draw.

-> GameResult

The game result to fold.

-> x 

Fold a game result.

playerGameResultSource

Arguments

:: x

If player 1 won.

-> x

If player 2 won.

-> x

If the game was a draw.

-> GameResult

The game result to fold.

-> x 

Fold a game result.

Construction

winSource

Arguments

:: Player

The player to win.

-> GameResult 

Construct a game result with a win for the given player.

player1Wins :: GameResultSource

Construct a game result with a win for player 1.

player2Wins :: GameResultSource

Construct a game result with a win for player 2.

draw :: GameResultSource

Construct a game result that is a draw.

Decisions

isPlayer1Wins :: GameResult -> BoolSource

Returns whether or not player 1 won for the game result.

isPlayer2Wins :: GameResult -> BoolSource

Returns whether or not player 2 won for the game result.

isDraw :: GameResult -> BoolSource

Returns whether the game result is a draw.