Skip to content

Instantly share code, notes, and snippets.

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