simple-money-0.2.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 #

Read USD Source # 
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 

data EUR Source #

Euro

Constructors

EUR 

data BTC Source #

Bitcoin

Constructors

BTC 

data LTC Source #

Litecoin

Constructors

LTC 

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 :: [((TypeRep, TypeRep), Double)] -> ExchangeRates Source #

Construct the exchange dictionary from TypeReps of 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 #

Read a => Read (Money a) Source # 
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)