Created
April 23, 2019 16:46
-
-
Save zemm/b83bcc365fafb52c4a255cf3b1b03b6e to your computer and use it in GitHub Desktop.
Suites
This file contains 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
-- Simple version | |
deck :: [(String, Int)] | |
deck = | |
[ (s,n) | |
| s <- ["Spade","Heard","Club","Diamond"] | |
, n <- [1..13] | |
] |
This file contains 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
-- Typed version | |
data Suite | |
= Spade | Heart | Club | Diamond | |
deriving (Show, Bounded, Enum) | |
data Rank = | |
Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace | |
deriving (Show, Bounded, Enum, Eq, Ord) | |
type Card = (Suite, Rank) | |
deck :: [Card] | |
deck = | |
[ (s,r) | |
| s <- [minBound..maxBound] | |
, r <- [minBound..maxBound] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment