currencies-0.1.0.0: Currencies representation, pretty printing and conversion

Safe HaskellSafe
LanguageHaskell2010

Data.Currency.Amounts

Contents

Description

Operations upon monetary Amounts

Converting amounts

>>> convert USD (Amount EUR 23482.34)
Amount USD 27709.1612
>>> prettyPrint $ convert USD (Amount EUR 23482.34)
"USD 27,709.16"

Comparing amounts

>>> compareAmounts  (Amount EUR 1000) (Amount BTC 1)
LT

Synopsis

Monetary Amount

data Amount c Source #

Monetary amounts

Constructors

Amount c Double 

Instances

Eq c => Eq (Amount c) Source # 

Methods

(==) :: Amount c -> Amount c -> Bool #

(/=) :: Amount c -> Amount c -> Bool #

Currency c => Ord (Amount c) Source # 

Methods

compare :: Amount c -> Amount c -> Ordering #

(<) :: Amount c -> Amount c -> Bool #

(<=) :: Amount c -> Amount c -> Bool #

(>) :: Amount c -> Amount c -> Bool #

(>=) :: Amount c -> Amount c -> Bool #

max :: Amount c -> Amount c -> Amount c #

min :: Amount c -> Amount c -> Amount c #

Read c => Read (Amount c) Source # 
Show c => Show (Amount c) Source # 

Methods

showsPrec :: Int -> Amount c -> ShowS #

show :: Amount c -> String #

showList :: [Amount c] -> ShowS #

Converting

toUSD :: Currency c => Amount c -> Amount USD Source #

Convert an Amount of an arbitrary currency to USD

fromUSD :: Currency c => c -> Amount USD -> Amount c Source #

Convert an Amount from USD to a given Currency

convert :: (Currency c', Currency c) => c' -> Amount c -> Amount c' Source #

Convert an Amount to a given Currency

Comparing

compareAmounts :: (Currency c1, Currency c2) => Amount c1 -> Amount c2 -> Ordering Source #

Compare two Amounts of arbitrary currencies