The SquareRank
data type and related functions and definitions.
Internal.SquareRank
A SquareRank
is a type representing a rank on a chess board, i.e. one of
the horizontal rows labeled 1-8.
fromChar : Char -> Maybe SquareRank
Tries to convert a Char
to a SquareRank
. Returns Nothing
if the
character is not a digit in the range 1-8.
fromChar '5' == Just five
List.map fromChar [ '1', 'x', '8' ] == [ Just one, Nothing, Just eight ]
fromString : String -> Maybe SquareRank
Tries to convert a String
to a SquareRank
by looking at the first
character of the string. Returns Nothing
if the first character is not a
digit in the range 1-8.
fromChar '5' == Just five
List.map fromChar [ '1', 'x', '8' ] == [ Just one, Nothing, Just eight ]
toChar : SquareRank -> Char
Converts a SquareRank
to a Char
in the range 1-8.
toChar three == '3'
List.map toChar all == [ '1', '2', '3', '4', '5', '6', '7', '8' ]
toString : SquareRank -> String
Converts a SquareRank
to a single-character String
consisting of a
letter in the range 1-8.
toString three == "3"
List.map toString all == [ "1", "2", "3", "4", "5", "6", "7", "8" ]
all : List SquareRank
List of all ranks on the board.
one : SquareRank
The first rank, seen from white's point of view.
two : SquareRank
The second rank, seen from white's point of view.
three : SquareRank
The third rank, seen from white's point of view.
four : SquareRank
The fourth rank, seen from white's point of view.
five : SquareRank
The fifth rank, seen from white's point of view.
six : SquareRank
The sixth rank, seen from white's point of view.
seven : SquareRank
The seventh rank, seen from white's point of view.
eight : SquareRank
The eighth rank, seen from white's point of view.
distance : SquareRank -> SquareRank -> Basics.Int
The vertical distance between two ranks.
distance one eight == 7
distance five three == 2
toIndex : SquareRank -> Basics.Int
Convert a rank to an index in the range 0 (for the first rank) to 7 (for the last rank).