chessica-0.1.0.0: A Library for Chess Game Logic
Copyright(c) Michael Szvetits 2023
LicenseBSD-3-Clause (see the file LICENSE)
Maintainertypedbyte@qualified.name
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

Chess.Board.Position

Description

Types and functions to represent and manipulate positions on a chess board.

Synopsis

Representing Positions

data Position Source #

Represents a position on the chess board.

Instances

Instances details
Read Position Source # 
Instance details

Defined in Chess.Board.Position

Show Position Source # 
Instance details

Defined in Chess.Board.Position

Eq Position Source # 
Instance details

Defined in Chess.Board.Position

Ord Position Source # 
Instance details

Defined in Chess.Board.Position

mkPosition Source #

Arguments

:: Alternative f 
=> Int

The row of the position, where 0 is the row labelled 1.

-> Int

The column of the position, where 0 is the column labelled A.

-> f Position

The position, if it is within the bounds of the chess board.

Creates a position from row and column indices.

boundedPosition Source #

Arguments

:: Int

The row of the position, where 0 is the row labelled 1.

-> Int

The column of the position, where 0 is the column labelled A.

-> Position

The position, where out-of-bounds indices are limited to the valid range.

Creates a position from row and column indices.

Manipulating Positions

offset Source #

Arguments

:: Alternative f 
=> Direction

The offset to be added to the position.

-> Position

The original position.

-> f Position

The new position, if it is within the bounds of the chess board.

Adds an offset to a position, yielding a new position.

boundedOffset Source #

Arguments

:: Direction

The offset to be added to the position.

-> Position

The original position.

-> Position

The new position, where out-of-bounds indices are limited to the valid range.

Adds an offset to a position, yielding a new position.