Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active August 16, 2017 11:10
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 deque-blog/9bd81d6594fdf241c8af5b15a06f574b to your computer and use it in GitHub Desktop.
Save deque-blog/9bd81d6594fdf241c8af5b15a06f574b to your computer and use it in GitHub Desktop.
-- Given these expressions
let a = money 30 "USD"
let b = money 25 "EUR"
let c = money 1000 "JPY"
-- Add the different currencies
add (add a (multiply b 2)) c
-- It returns the following AST:
MoneyAdd
[ MoneyAdd
[ KnownAmount (Money {amount = 30.0, currency = "USD"})
, MoneyMul (KnownAmount (Money {amount = 25.0, currency = "EUR"})) 2.0]
, KnownAmount (Money {amount = 1000.0, currency = "JPY"})]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment