1
Fork 0
This repository has been archived on 2023-12-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project2-patience/lib/CardDeck.hs

46 lines
997 B
Haskell

module CardDeck (
generateCards,
generateShuffledCards
) where
import Shuffle
-- Colors of cards
data CardType = Clubs
| Diamonds
| Hearts
| Spades
| NoneType
deriving (Show, Enum, Eq)
-- Values of cards
data CardValue = Ace
| Two
| Three
| Four
| Five
| Six
| Seven
| Eight
| Nine
| Ten
| Jack
| Queen
| King
| NoneValue
deriving (Show, Enum, Eq)
-- A card has a type and a value
type Card = (CardType, CardValue)
-- A deck of cards
type Deck = [Card]
generateCards :: Deck
generateCards = [(cType, cValue) | cType <- types, cValue <- values]
where types = init $ enumFrom Clubs
values = init $ enumFrom Ace
generateShuffledCards :: Deck
generateShuffledCards = shuffle generateCards