module Data.Currency.Currencies
(
Currency(..)
, CurrencyType(..)
, BTC(..)
, CLP(..)
, EUR(..)
, USD(..)
) where
class (Show c, Eq c) => Currency c where
currencyType :: c -> CurrencyType
isoCode :: c -> String
isoNumericCode :: c -> String
decimalDigits :: c -> Int
symbol :: c -> String
exchangeUSD :: c -> Double
countries :: c -> [String]
data CurrencyType
= Circulating
| Local
| Supranational
| Cryptocurrency
| Fictional
deriving (Show, Read, Eq)
data BTC = BTC deriving (Show, Read, Eq)
data CLP = CLP deriving (Show, Read, Eq)
data EUR = EUR deriving (Show, Read, Eq)
data USD = USD deriving (Show, Read, Eq)
instance Currency BTC where
currencyType _ = Cryptocurrency
isoCode = show
isoNumericCode _ = ""
decimalDigits _ = 8
symbol _ = "B"
exchangeUSD _ = 4237.88
countries _ = []
instance Currency CLP where
currencyType _ = Circulating
isoCode = show
isoNumericCode _ = "152"
decimalDigits _ = 0
symbol _ = "$"
exchangeUSD _ = 0.0015
countries _ = ["CL"]
instance Currency EUR where
currencyType _ = Circulating
isoCode = show
isoNumericCode _ = "978"
decimalDigits _ = 2
symbol _ = "€"
exchangeUSD _ = 1.18
countries _ = ["AD", "AT", "BE", "CY", "EE", "FI", "FR", "DE", "GR"
, "GP", "IE", "IT", "LV", "LT", "LU", "MT", "MQ", "YT", "MC"
, "ME", "NL", "PT", "RE", "BL", "PM", "SM", "SK", "SI", "ES"]
instance Currency USD where
currencyType _ = Circulating
isoCode = show
isoNumericCode _ = "840"
decimalDigits _ = 2
symbol _ = "$"
exchangeUSD _ = 1.0
countries _ = ["US", "AS", "BB", "BM", "IO", "VG", "BQ", "EC", "MH"
, "FM", "MP", "PW", "PA", "PR", "TL", "TC", "VI"]