Copyright | (c) Michael Szvetits 2023 |
---|---|
License | BSD-3-Clause (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Types and functions to represent and manipulate positions on a chess board.
Synopsis
- data Position
- mkPosition :: Alternative f => Int -> Int -> f Position
- boundedPosition :: Int -> Int -> Position
- offset :: Alternative f => Direction -> Position -> f Position
- boundedOffset :: Direction -> Position -> Position
Representing Positions
Represents a position on the chess board.
:: 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.
:: 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
:: 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.