Author : Joe Fredette License : BSD3 Copyright : Joe Fredette
Maintainer : Joe Fredette jfredett.at.gmail.dot.com Stability : Unstable Portability : portable
- class (Eq s, Eq i, Show s, Show i) => Card s i where
- type Cards s i = [CardT s i]
- class Parse a where
- newtype Deck s i = Deck (Cards s i)
- type DeckST s i = State (Deck s i)
- mkDeck :: (Bounded s, Bounded i, Enum s, Enum i, Card s i) => Deck s i
- shuffleDeck :: (Card s i, RandomGen g) => Deck s i -> g -> Deck s i
- shuffleDeckIO :: Card s i => Deck s i -> IO (Deck s i)
- dealHands :: Card s i => Int -> Int -> DeckST s i [Hand s i]
- dealHand :: Card s i => Int -> DeckST s i (Hand s i)
- newtype Hand s i = Hand (Cards s i)
- module Data.HCard.Instances
The Main class, this is -- effectively -- a type-indexed record. Specifically, it requires two types, one representing the suit, the other representing the index/rank. The suit, index, and construct functions are generic forms of the record accessors.
TODO: Write deriving instance?
Separate Deck from Hand, even though the types are isomorphic, we don't want shuffling to be to liberal.
TODO: Make Deck clever enough to support reshuffling when the deck runs out -- it should store cards it has already seen till it runs out of the main deck, reshuffle, redeal.
Creates a deck, used as in: `mkDeck::your deck type here`, or w/ inference.
Shuffles a deck given a generator
n hands of
qty cards, written in the state monad.
Helper for dealHands, also somewhat useful, equiv. to `dealHands 1 qty`
A type to separate Hands from Decks.