-module(piece). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([to_string/1]). -export_type([piece/0, kind/0]). -type piece() :: {piece, color:color(), kind()}. -type kind() :: pawn | knight | bishop | rook | queen | king. -spec to_string(piece()) -> binary(). to_string(Piece) -> Kind = case erlang:element(3, Piece) of pawn -> <<"Pawn"/utf8>>; knight -> <<"Knight"/utf8>>; bishop -> <<"Bishop"/utf8>>; rook -> <<"Rook"/utf8>>; queen -> <<"Queen"/utf8>>; king -> <<"King"/utf8>> end, Color = case erlang:element(2, Piece) of white -> color:to_string(white); black -> color:to_string(black) end, <<<>/binary, Kind/binary>>.