Skip to content

Instantly share code, notes, and snippets.

@joshvera
Created July 12, 2016 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshvera/606ea0a3c10125c75febf879173c378b to your computer and use it in GitHub Desktop.
Save joshvera/606ea0a3c10125c75febf879173c378b to your computer and use it in GitHub Desktop.
parseRank :: String -> Rank
parseRank string = case string of
"clubs" -> Club
"diamonds" -> Diamond
"spades" -> Spade
"hearts" -> Heart
_ -> Heart
parseNumber :: String -> Number
parseNumber string = case string of
"ace" -> Ace
"two" -> Two
"three" -> Three
"four" -> Four
"five" -> Five
"six" -> Six
"seven" -> Seven
"eight" -> Eight
"nine" -> Nine
"ten" -> Ten
"jack" -> Jack
"queen" -> Queen
"king" -> King
parseString :: String -> Card
parseString string = case words string of
[number, theWordOf, rank] -> Card number (parseRank rank)
_ -> Card Ace Heart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment