Created
May 1, 2021 10:15
-
-
Save r17x/67d0d5e875c1a75ad421a29ebac05ee0 to your computer and use it in GitHub Desktop.
Payment Case with FP
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 checkNumber = int; | |
type cardNumber = string; | |
type cardType = | |
| Visa | |
| Mastercard; | |
type creditCardInfo = (cardNumber, cardType); | |
type paymentMethod = | |
| Cash | |
| Check(checkNumber) | |
| Card(creditCardInfo); | |
let cardTypeToString = | |
fun | |
| Visa => "Visa" | |
| Mastercard => "Mastercard"; | |
let payme = | |
fun | |
| Cash => "Pay with Cash" | |
| Check(checkNumber) => | |
"Pay with check number: " ++ checkNumber->string_of_int | |
| Card((cardNumber, cardType)) => | |
"Pay with a card " | |
++ cardType->cardTypeToString | |
++ " and number " | |
++ cardNumber; | |
// Bayar utang kamu kisanak!!! | |
Check(12388234)->payme; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment