simple-money-0.1.0.1: Simple library to handle and interexchange money

Safe HaskellSafe
LanguageHaskell2010

Data.Money

Description

Simple currency handling and exchange library

Synopsis

Documentation

data USD Source #

U.S. Dollar

Constructors

USD 

Instances

Eq USD Source # 

Methods

(==) :: USD -> USD -> Bool #

(/=) :: USD -> USD -> Bool #

Show USD Source # 

Methods

showsPrec :: Int -> USD -> ShowS #

show :: USD -> String #

showList :: [USD] -> ShowS #

CurrencySymbol USD Source #

Currency symbols can have exchange rates

data RUB Source #

Russian Ruble

Constructors

RUB 

Instances

Eq RUB Source # 

Methods

(==) :: RUB -> RUB -> Bool #

(/=) :: RUB -> RUB -> Bool #

Show RUB Source # 

Methods

showsPrec :: Int -> RUB -> ShowS #

show :: RUB -> String #

showList :: [RUB] -> ShowS #

CurrencySymbol RUB Source # 

data EUR Source #

Euro

Constructors

EUR 

Instances

Eq EUR Source # 

Methods

(==) :: EUR -> EUR -> Bool #

(/=) :: EUR -> EUR -> Bool #

Show EUR Source # 

Methods

showsPrec :: Int -> EUR -> ShowS #

show :: EUR -> String #

showList :: [EUR] -> ShowS #

CurrencySymbol EUR Source # 

data BTC Source #

Bitcoin

Constructors

BTC 

Instances

Eq BTC Source # 

Methods

(==) :: BTC -> BTC -> Bool #

(/=) :: BTC -> BTC -> Bool #

Show BTC Source # 

Methods

showsPrec :: Int -> BTC -> ShowS #

show :: BTC -> String #

showList :: [BTC] -> ShowS #

CurrencySymbol BTC Source # 

data LTC Source #

Litecoin

Constructors

LTC 

Instances

Eq LTC Source # 

Methods

(==) :: LTC -> LTC -> Bool #

(/=) :: LTC -> LTC -> Bool #

Show LTC Source # 

Methods

showsPrec :: Int -> LTC -> ShowS #

show :: LTC -> String #

showList :: [LTC] -> ShowS #

CurrencySymbol LTC Source # 

class (Typeable a, Eq a) => CurrencySymbol a Source #

Things that can be looked up in the rates dictionary

class ScalableAdditive a where Source #

Things that can be scaled (or shrinked) with scalars, and added (subtracted) together (like money or a mining hashrate)

Minimal complete definition

(^*), (^+^), (^-^)

Methods

(^*) :: a -> Double -> a Source #

(^+^) :: a -> a -> a Source #

(^-^) :: a -> a -> a Source #

(^/) :: a -> Double -> a Source #

Instances

ScalableAdditive (Money a) Source #

Money can be scaled or added together when they have equal types

Methods

(^*) :: Money a -> Double -> Money a Source #

(^+^) :: Money a -> Money a -> Money a Source #

(^-^) :: Money a -> Money a -> Money a Source #

(^/) :: Money a -> Double -> Money a Source #

data ExchangeRates Source #

A dictionary of exchange rates (indexed by pairs of base and foreign currency symbols)

makeExchangeRates :: (CurrencySymbol a, CurrencySymbol b) => [((a, b), Double)] -> ExchangeRates Source #

Construct the exchange dictionary from instances of CurrencySymbol

data Money a Source #

Polymorphic type representing money

Instances

Eq a => Eq (Money a) Source # 

Methods

(==) :: Money a -> Money a -> Bool #

(/=) :: Money a -> Money a -> Bool #

Show a => Show (Money a) Source # 

Methods

showsPrec :: Int -> Money a -> ShowS #

show :: Money a -> String #

showList :: [Money a] -> ShowS #

ScalableAdditive (Money a) Source #

Money can be scaled or added together when they have equal types

Methods

(^*) :: Money a -> Double -> Money a Source #

(^+^) :: Money a -> Money a -> Money a Source #

(^-^) :: Money a -> Money a -> Money a Source #

(^/) :: Money a -> Double -> Money a Source #

makeMoney :: CurrencySymbol a => Double -> a -> Money a Source #

Money constructor over currency symbols

amount :: Money a -> Double Source #

Extract amount (i.e. quantity of the asset) from Money

symbol :: Money a -> a Source #

Extract the currency symbol from Money

findRate :: (CurrencySymbol a, CurrencySymbol b) => ExchangeRates -> a -> b -> Maybe Double Source #

Returns the direct conversion rate or tries to compute the reverse one

exchangeTo :: (CurrencySymbol a, CurrencySymbol b) => ExchangeRates -> Money a -> b -> Maybe (Money b) Source #

Maybe convert the money to designated currency symbol

sampleRates :: ExchangeRates Source #

Sample rates dictionary (19 Jan 2017)