# poker

committed 3fb25f7

Testing

# Cards/Card.hs

` `
` import Cards.Suit`
` import Cards.Rank`
`+import Test.QuickCheck`
` `
` data Card = Card {`
`   rank :: Rank,`
` allCards = do r <- [Two ..]`
`               s <- [Spades ..]`
`               return (r ! s)`
`+`
`+instance Arbitrary Card where`
`+  arbitrary = elements allCards`
`+`
`+prop_ana_cata :: Card -> Bool`
`+prop_ana_cata c = card c (!) == c`
`+`
`+prop_rank :: Card -> Bool`
`+prop_rank c = card c const == rank c`
`+`
`+prop_suit :: Card -> Bool`
`+prop_suit c = card c (flip const) == suit c`

# Cards/Rank.hs

` module Cards.Rank where`
` `
`+import Test.QuickCheck`
`+`
` data Rank = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace`
`   deriving (Eq, Ord, Enum, Bounded)`
` `
` `
` rank' :: (Enum a) => Int -> a`
` rank' = toEnum . subtract 2`
`+`
`+instance Arbitrary Rank where`
`+  arbitrary = elements [Two ..]`
`+`
`+prop_rank' :: Int -> Property`
`+prop_rank' n = n >= 2 && n <= 14 ==> fromEnum (rank' n :: Rank) + 2 == n`

# Cards/Suit.hs

` module Cards.Suit where`
` `
`+import Test.QuickCheck`
`+`
` data Suit = Spades | Clubs | Hearts | Diamonds`
`   deriving (Eq, Enum, Bounded)`
` `
`   show Clubs = "C"`
`   show Hearts = "H"`
`   show Diamonds = "D"`
`+`
`+instance Arbitrary Suit where`
`+  arbitrary = elements [Spades ..]`

# poker.cabal

`   Description:     Choose the new, split-up base package.`
` `
` Library`
`-  Build-Depends: base < 5 && >= 3, mtl`
`+  Build-Depends: base < 5 && >= 3, mtl, QuickCheck >= 2, HUnit`
` `
`   GHC-Options:    -Wall`
`   Exposed-Modules: Cards.Card,`
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.