Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created August 14, 2017 16:07
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
evalMoneyIn :: (Conversion -> Maybe Rate) -> MoneyBag -> Currency -> Maybe Money
evalMoneyIn findRate (MoneyBag m) refCurrency = do
let convert (curr, amount) = (* amount) <$> findRate (curr, refCurrency)
amounts <- mapM convert (M.toList m)
pure $ Money { amount = sum amounts, currency = refCurrency }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment