Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Created May 4, 2015 14:18
Show Gist options
  • Save vgaltes/eea502a4bc3b2ce9475a to your computer and use it in GitHub Desktop.
Save vgaltes/eea502a4bc3b2ce9475a to your computer and use it in GitHub Desktop.
FSharp Bank Kata - pattern matching
let withdraw amount currency {Amount = (oldAmount, _)} =
match oldAmount - amount with
| newAmount when newAmount < 0 -> Failure("This bank account cannot be overdrawn.")
| newAmount -> Success {Amount = (oldAmount - amount, USD)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment