Safe Haskell | None |
---|---|
Language | Haskell2010 |
User board and its processing functions
Documentation
type CardParseResult = Either String Card Source #
Parsed card result wrapper which also holds the possible err msg
getUserBoard :: [String] -> Either String Board Source #
This function gets a list of strings which items represents a card notation.
Returns Either
type, where Left
is String
with error message,
and Right
is Board
type.
Processes only list of length 13.
Method is going to fail the list with duplicates.
Examples:
cards = [ "Ah", "Qd", "Kc", "Ts", "Jc", "6h", "2h", "3h", "8c", "4c", "7s", "9c", "Tc" ] getUserBoard cards =Right
[ [Card
{value = Ace, suit = Hearts},Card
{value = Queen, suit = Diamonds},Card
{value = King, suit = Clubs} ], [Card
{value = Ten, suit = Spades},Card
{value = Jack, suit = Clubs},Card
{value = Six, suit = Hearts},Card
{value = Two, suit = Hearts},Card
{value = Three, suit = Hearts} ], [Card
{value = Eight, suit = Clubs},Card
{value = Four, suit = Clubs},Card
{value = Seven, suit = Spades},Card
{value = Nine, suit = Clubs},Card
{value = Ten, suit = Clubs} ] ] cardsTwo = [ "Az", "Qx", "Kf", "Xs", "Jc", "6h", "2h", "3h", "8c", "4c", "7s", "9c", "Tc" ] getUserBoard cardsTwo =Left
"Some cards failed to be parsed: There is no card suit marked as 'z'; There is no card suit marked as 'x'; There is no card suit marked as 'f'; There is no broadway card, which could be represented with 'X';"