Skip to content

Instantly share code, notes, and snippets.

@jasonneylon
Created February 4, 2021 14:54
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 jasonneylon/9b7da72bb5aae7a9783944953948bcc2 to your computer and use it in GitHub Desktop.
Save jasonneylon/9b7da72bb5aae7a9783944953948bcc2 to your computer and use it in GitHub Desktop.
Blackjack functional domain modelling example team 2
type rank = Ace | Two | Three| Four | Five | Six | Seven| Eight | Nine | Ten | Jack | Queen | King ;
type suit = Spade | Hearts | Diamond | Club
type card = { rank, suit }
type deck = list(card)
/* type deck = List(card) | EmptyDeck */
/* draw card(s) (don't forget the effect on the deck)
ensure the deck is shuffled
calculate scores
determine the winner (player or dealer) or draw
a way to determine the color of a card for display purposes
*/
// Tagged Type
type shuffledDeck = ShuffleDeck(deck)
type shuffleDeck = deck => shuffledDeck
type shoe = list(deck)
/* type shoe = list(list(card)) */
type shuffledShoe = ShuffleShoe(shoe);
type shuffleShoe = shoe => shuffledShoe;
/* type drawCard = shuffledDeck => (shuffledDeck, card) */
/* type shoe = list(deck) */
type drawCard = shuffledShoe => (shuffledShoe, card)
type hand = list(card)
/* type player?? */
type score = list(int)
type calculateScoreFromRank = Rank => (Int, Int)
type calculateScore = list(card) => score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment