Created
February 4, 2021 14:54
-
-
Save jasonneylon/9b7da72bb5aae7a9783944953948bcc2 to your computer and use it in GitHub Desktop.
Blackjack functional domain modelling example team 2
This file contains hidden or 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
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