The Square data type and related functions and definitions.
Create a square from a SquareFile and a SquareRank.
The file of a square.
The rank of a square.
Tries to convert a String to a Square, by looking at the first two
characters of the string. If the two first characters are not a valid square
string, returns Nothing.
fromString "g8" == Just g8
fromString "b1d3" == Just b1
fromString "Donald Trump" == NothingConverts a Square to a String in standard algebraic notation
toString e4 == "e4"Tries to convert an Int to a Square, using the mapping a1 <-> 0,
b1 <-> 1, ..., h8 <-> 63.
fromInt 0 == Just a1
fromInt 1 == Just b1
fromInt 63 == Just h8
fromInt -1 == Nothing
fromInt 100 == NothingConverts a Square to an Int in the 0..63 range, using the mapping
a1 <-> 0, b1 <-> 1, ..., h8 <-> 63.
toInt a1 == 0
toInt b1 == 1
toInt a2 == 8
toInt h8 == 63The horizontal distance between two squares.
fileDistance a1 d3 == 3
fileDistance c1 c7 == 0
fileDistance h8 a3 == 7The vertical distance between two squares.
rankDistance a1 b4 == 3
rankDistance c2 h2 == 0
rankDistance a8 c1 == 7The distance between two squares, measured as the maximum of the vertical and horizontal distances, or the number of king moves required to get from one square to the other on an empty board.
distance a1 b4 == 3
distance h8 b1 == 7
distance f3 e4 == 1A list of all squares on the board.
The a1 square.
The b1 square.
The c1 square.
The d1 square.
The e1 square.
The f1 square.
The g1 square.
The h1 square.
The a2 square.
The b2 square.
The c2 square.
The d2 square.
The e2 square.
The f2 square.
The g2 square.
The h2 square.
The a3 square.
The b3 square.
The c3 square.
The d3 square.
The e3 square.
The f3 square.
The g3 square.
The h3 square.
The a4 square.
The b4 square.
The c4 square.
The d4 square.
The e4 square.
The f4 square.
The g4 square.
The h4 square.
The a5 square.
The b5 square.
The c5 square.
The d5 square.
The e5 square.
The f5 square.
The g5 square.
The h5 square.
The a6 square.
The b6 square.
The c6 square.
The d6 square.
The e6 square.
The f6 square.
The g6 square.
The h6 square.
The a7 square.
The b7 square.
The c7 square.
The d7 square.
The e7 square.
The f7 square.
The g7 square.
The h7 square.
The a8 square.
The b8 square.
The c8 square.
The d8 square.
The e8 square.
The f8 square.
The g8 square.
The h8 square.
Type representing one of the 64 squares of the board.