Created
August 14, 2017 16:07
-
-
Save deque-blog/9ee91432af94905cfbb5b3da4fbcb4e5 to your computer and use it in GitHub Desktop.
This file contains 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
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