This module defines the PieceType
type and related functions. A
PieceType
value is basically an uncolored chess piece.
Internal.PieceType
A type representing the type of a chess piece, i.e. pawn, knight, bishop, etc. It's essentially a chess piece without information about its color.
pawn : PieceType
Value representing a pawn.
knight : PieceType
Value representing a knight.
bishop : PieceType
Value representing a bishop.
rook : PieceType
Value representing a rook.
queen : PieceType
Value representing a queen.
king : PieceType
Value representing a king.
all : List PieceType
List of all piece types.
all =
[ pawn, knight, bishop, rook, queen, king ]
promotionPieces : List PieceType
List of all piece types to which a pawn can promote.
promotionPieces =
[ queen, rook, bishop, knight ]
fromChar : Char -> Maybe PieceType
Tries to convert a character to a PieceType
. Accepts both uppercase
and lowercase letters; returns Nothing
if the character is not one of the
piece letters used in English algebraic notation.
fromChar 'P' == Just pawn
fromChar 'r' == Just rook
fromChar 'x' == Nothing
fromString : String -> Maybe PieceType
Tries to convert a string to a PieceType
, based on the first character
in the string. Accepts both uppercase and lowercase letters; returns
Nothing
if the character is not one of the piece letters used in English
algebraic notation.
fromString "k" == Just king
fromString "Qa4+" == Just queen
fromString "x" == Nothing
toChar : PieceType -> Char
Converts a PieceType
to the corresponding character used in English
algebraic notation.
toChar pawn == 'P'
toChar knight == 'N'
toChar bishop == 'B'
toChar rook == 'R'
toChar queen == 'Q'
toChar king == 'K'
toString : PieceType -> String
Converts a PieceType
to the a single-character string containing the
corresponding piece letter used in English algebraic notation.
toString pawn == "P"
toString knight == "N"
toString bishop == "B"
toString rook == "R"
toString queen == "Q"
toString king == "K"