| Portability | portable | 
|---|---|
| Stability | provisional | 
| Maintainer | lemmih@gmail.com | 
| Safe Haskell | None | 
Data.Poker
Description
- handValue :: CardSet -> HandValue
 - handValue_n :: Int -> CardSet -> HandValue
 - numericalHandValue :: CardSet -> NumericalHandValue
 - numericalHandValue_n :: Int -> CardSet -> NumericalHandValue
 - foldlSevenCards :: (CardSet -> a -> a) -> a -> CardSet -> a
 - foldlFiveCards :: (CardSet -> a -> a) -> a -> CardSet -> a
 - foldlFourCards :: (CardSet -> a -> a) -> a -> CardSet -> a
 - foldlThreeCards :: (CardSet -> a -> a) -> a -> CardSet -> a
 - foldlTwoCards :: (CardSet -> a -> a) -> a -> CardSet -> a
 - foldlOneCard :: (CardSet -> a -> a) -> a -> CardSet -> a
 - enumerateFiveCards :: Monad m => CardSet -> (CardSet -> m ()) -> m ()
 - data HandValue
 - data NumericalHandValue
 - data ConsecutiveHandValue
 - data Card
 - data Rank
 - data Suit
 - type Kicker = Rank
 - mkCard :: Rank -> Suit -> Card
 - cardRank :: Card -> Rank
 - cardSuit :: Card -> Suit
 - data CardSet
 - toList :: CardSet -> [Card]
 - fromList :: [Card] -> CardSet
 - singleton :: Card -> CardSet
 - size :: CardSet -> Int
 - empty :: CardSet
 - isEmpty :: CardSet -> Bool
 - union :: CardSet -> CardSet -> CardSet
 - intersection :: CardSet -> CardSet -> CardSet
 - inverse :: CardSet -> CardSet
 - member :: CardSet -> Card -> Bool
 - countRank :: CardSet -> Rank -> Int
 - countSuit :: CardSet -> Suit -> Int
 - isNoPair :: HandValue -> Bool
 - isOnePair :: HandValue -> Bool
 - isTwoPair :: HandValue -> Bool
 - isThreeOfAKind :: HandValue -> Bool
 - isStraight :: HandValue -> Bool
 - isFlush :: HandValue -> Bool
 - isFullHouse :: HandValue -> Bool
 - isFourOfAKind :: HandValue -> Bool
 - isStraightFlush :: HandValue -> Bool
 
Evaluation
Find the strongest possible hand using the given cards.
Find the strongest possible hand using the given cards. This function is
   significantly faster than handValue if the size of the card set
   is constant.
Arguments
| :: CardSet | Available cards.  | 
| -> NumericalHandValue | 
Find the strongest possible hand using the given cards.
It is significantly faster to compute a NumericalHandValue than a
   HandValue. Use this function instead of handValue when possible.
Arguments
| :: Int | Size of card set.  | 
| -> CardSet | Available cards.  | 
| -> NumericalHandValue | 
Find the strongest possible hand using the given cards. This function is
   significantly faster than numericalHandValue if the size of the card set
   is constant.
It is significantly faster to compute a NumericalHandValue than a
   HandValue. Use this function instead of handValue_n when possible.
Enumeration
Strict left-fold over all 7 card combinations excluding the dead cards.
Strict left-fold over all 5 card combinations excluding the dead cards.
Strict left-fold over all 4 card combinations excluding the dead cards.
Strict left-fold over all 3 card combinations excluding the dead cards.
Strict left-fold over all 2 card combinations excluding the dead cards.
Strict left-fold over all 1 card combinations excluding the dead cards.
enumerateFiveCards :: Monad m => CardSet -> (CardSet -> m ()) -> m ()Source
Given a set of dead cards, enumerate over all possible selections of five cards. The generated card sets do not contain the dead cards.
HandValue
This structure represents the value of a poker hand as a high-level ADT.
The following must be true for a HandValue to be valid:
- All kickers must be in decending order.
 -  No 
Rankmay not occur twice. - The kickers may not construct higher-value hands.
 
For example, 
       is not a valid HandValue.
NoPair Six Five Four Three Two
data NumericalHandValue Source
Isomorphic to HandValue but computed much more efficiently.
If possible, this is the structure to use.
data ConsecutiveHandValue Source
Isomorphic to HandValue but stored more efficiently.
This structure has the special property of being bounded and an enum. It is especially useful as an Array index.
Cards
Card sets
A set of cards.
O(n). The number of cards in the set.
Performance note: Try to avoid using this function in an inner loop.
intersection :: CardSet -> CardSet -> CardSetSource
O(1). The intersection of two sets.
inverse :: CardSet -> CardSetSource
O(1). Find the inverse set such that set  and
   intersection inverse = emptyset .
union inverse set = fromList [minBound ..]
countRank :: CardSet -> Rank -> IntSource
O(n). Count the number of cards with a specific Rank in a set.
countSuit :: CardSet -> Suit -> IntSource
O(n). Count the number of cards with a specific Suit in a set.
Auxiliary functions
HandValue
isThreeOfAKind :: HandValue -> BoolSource
True for all ThreeOfAKind hands.
isStraight :: HandValue -> BoolSource
True for all Straight hands.
isFullHouse :: HandValue -> BoolSource
True for all FullHouse hands.
isFourOfAKind :: HandValue -> BoolSource
True for all FourOfAKind hands.
isStraightFlush :: HandValue -> BoolSource
True for all StraightFlush hands.