Skip to content

Instantly share code, notes, and snippets.

@zemm
Created April 23, 2019 16:46
Show Gist options
  • Save zemm/b83bcc365fafb52c4a255cf3b1b03b6e to your computer and use it in GitHub Desktop.
Save zemm/b83bcc365fafb52c4a255cf3b1b03b6e to your computer and use it in GitHub Desktop.
Suites
-- Simple version
deck :: [(String, Int)]
deck =
[ (s,n)
| s <- ["Spade","Heard","Club","Diamond"]
, n <- [1..13]
]
-- 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