chesshs-0.2.1: Simple library for validating chess moves and parsing PGN files

Safe HaskellSafe-Inferred
LanguageHaskell98

Chess

Description

The main move validation module. FEN parsing code is in Chess.FEN and PGN parsing is in Chess.PGN

Synopsis

Documentation

data MoveError Source

Constructors

WrongTurn

It's not your turn

NoPiece

There is no piece at the "from" position

IsCheck

Your king is checked and this move doesn't solve that

CausesCheck

After this move your king would be checked

InvalidMove

This is not how that piece works

OverPiece

You cannot move over other pieces

CapturesOwn

This move captures one of your own pieces

NoParse

I don't understand what you mean

data Color Source

Constructors

Black 
White 

Instances

data Piece Source

Constructors

Piece 

Fields

clr :: Color
 
piece :: PieceType
 

Instances

data Board Source

Constructors

Board 

Instances

strToPos :: String -> (Int, Int) Source

Takes a position like "a5" and returns the coordinates (0,4)

pieceAt :: Int -> Int -> Board -> Maybe Piece Source

Like pieceAtStr, but with coordinates instead of a string

pieceAtStr :: String -> Board -> Maybe Piece Source

What piece is currently at this position on the board?

move :: [Char] -> Board -> Either MoveError Board Source

Perform a move on the board in coordinate notation like "e2e4", returning either the new board or an error

moveSAN :: [Char] -> Board -> Either MoveError Board Source

Perform a move in SAN notation on the board and return either the new board or an error

check :: Color -> Board -> Bool Source

Is the player of the given colour check?

mate :: Color -> Board -> Bool Source

Is the player with the given colour checkmate

stalemate :: Color -> Board -> Bool Source

Can the player of the given colour make any move?