Skip to content

Instantly share code, notes, and snippets.

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 }
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()