Last active
August 29, 2015 14:04
-
-
Save jpfuentes2/bb16edfdb923d155bc69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveDataTypeable #-} | |
import Control.Monad.Random | |
import System.Random.Shuffle | |
import Data.Typeable | |
import Data.Data | |
import Control.Applicative | |
data Suit = Hearts | Clubs | Diamonds | Spades | |
deriving (Eq, Data, Typeable) | |
data Value | |
= Ace | |
| King | |
| Queen | |
| Jack | |
| Two | |
| Three | |
| Four | |
| Five | |
| Six | |
| Seven | |
| Eight | |
| Nine | |
| Ten | |
deriving (Eq, Enum, Bounded, Data, Typeable) | |
data Card = Card Suit Value | |
type Deck = [Card] | |
instance Show Card where | |
show (Card s v) = (show $ toConstr s) ++ ":" ++ (show $ toConstr v) | |
deck :: Deck | |
deck = Card <$> [Hearts, Clubs, Diamonds, Spades] <*> [Ace ..Ten] | |
main = do | |
deck <- evalRandIO $ shuffleM $ concat $ replicate 1 deck | |
print deck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment