Card datatypes and views
Use these for defining card-specifc game logic or for displaying specific cards.
A playing card face type.
Like the suit type above, this is useful for matching on different card faces, and does not induce an implicit order.
A playing card type.
Can either hold a card of suit and face, or a blank card.
Face numbers are designated from 1 to 13 for A-K. Games which treat the ace differently can specify their behavior through the game logic.
The blank variant is useful for displaying cards that have not been flipped over, for instance.
aceOfSpades =
Card Spades 1
blankCard =
BackConstruct a new card.
The first argument must be one of "spades", "diamonds", "clubs", or "hearts" (any case) for the card suit.
The second argument must be an integer from 1 to 13 for A-K.
Use Cards.defaultNew if you want a Card instead of a Maybe Card.
new "spades" 1 == Just (Card Spades Ace)
new "SPADES" 1 == Just (Card Spades Ace)
new "horses" 1 == Nothing
new "spades" 0 == NothingConstruct a new card with a default argument.
The first input is the default card to use if construction fails.
The remaining two inputs correspond to the two inputs for Cards.new.
defaultNew Back "spades" 1 == Card Spades Ace
defaultNew Back "SPADES" 1 == Card Spades Ace
defaultNew Back "horses" 1 == Back
defaultNew Back "spades" 0 == Back
A playing card suit type.
Useful for pattern matching behavior of different games that are based on the suit of the card.