Chadtech / elm-money / Money

All the worlds currencies.

Types


type Currency
    = USD
    | CAD
    | EUR
    | BTC
    | AED
    | AFN
    | ALL
    | AMD
    | ARS
    | AUD
    | AZN
    | BAM
    | BDT
    | BGN
    | BHD
    | BIF
    | BND
    | BOB
    | BRL
    | BWP
    | BYN
    | BZD
    | CDF
    | CHF
    | CLP
    | CNY
    | COP
    | CRC
    | CVE
    | CZK
    | DJF
    | DKK
    | DOP
    | DZD
    | EEK
    | EGP
    | ERN
    | ETB
    | GBP
    | GEL
    | GHS
    | GNF
    | GTQ
    | HKD
    | HNL
    | HRK
    | HUF
    | IDR
    | ILS
    | INR
    | IQD
    | IRR
    | ISK
    | JMD
    | JOD
    | JPY
    | KES
    | KHR
    | KMF
    | KRW
    | KWD
    | KZT
    | LAK
    | LBP
    | LKR
    | LTL
    | LVL
    | LYD
    | MAD
    | MDL
    | MGA
    | MKD
    | MMK
    | MOP
    | MUR
    | MXN
    | MYR
    | MZN
    | NAD
    | NGN
    | NIO
    | NOK
    | NPR
    | NZD
    | OMR
    | PAB
    | PEN
    | PHP
    | PKR
    | PLN
    | PYG
    | QAR
    | RON
    | RSD
    | RUB
    | RWF
    | SAR
    | SDG
    | SEK
    | SGD
    | SOS
    | SYP
    | THB
    | TND
    | TOP
    | TRY
    | TTD
    | TWD
    | TZS
    | UAH
    | UGX
    | UYU
    | UZS
    | VED
    | VND
    | XAF
    | XOF
    | YER
    | ZAR
    | ZMK
    | AOA
    | XCD
    | AWG
    | BSD
    | BBD
    | BMD
    | BTN
    | KYD
    | CUP
    | ANG
    | SZL
    | FKP
    | FJD
    | XPF
    | GMD
    | GIP
    | GYD
    | HTG
    | KPW
    | KGS
    | LSL
    | LRD
    | MWK
    | MVR
    | MRU
    | MNT
    | PGK
    | SHP
    | WST
    | STN
    | SCR
    | SLE
    | SBD
    | SSP
    | SRD
    | TJS
    | TMT
    | VUV
    | VES
    | ZMW
    | ZWL

This type represents all the possible currencies as currency codes.

Basics

all : List Currency

All the currency codes in a list

all =
    [ USD
    , EUR
    , CAD

    --..
    ]

toString : Currency -> String

Get the currency's code as a String

    toString CNY == "CNY"

fromString : String -> Maybe Currency

Attempt to derive a Currency from a String. This function presumes the String is a currency code like "USD".

    fromString "DKK" == Just DKK
    fromString "Danish Krone" == Nothing

Properties

toSymbol : Currency -> String

Get the symbol of a currency from its code

    toSymbol USD == "$"
    toSymbol CAD == "CA$"
    toSymbol BTC == "BTC"

Look at the documentation for toNativeSymbol for more details.

toName : { plural : Basics.Bool } -> Currency -> String

Get the name of a currency from its code

    toName { plural = True } EUR == "euros"
    toName { plural = False } ALL == "Albanian Lek"
    toName { plural = True } ALL == "Albanian lekë"

toNativeSymbol : Currency -> String

Get the native symbol of a currency from its code.

    toNativeSymbol LAK == "ກີບ"
    toSymbol LAK == "₭"

    toNativeSymbol CAD == "$"
    toSymbol CAD == "CA$"

    toNativeSymbol USD == "$"
    toSymbol USD == "$"

The native symbol is different from the symbol. The symbol is what is used in international currency exchange contexts. Imagine a currency exchange shop at an airport that lists several currencies right next to each other. The native symbol, however, is used in more local and natural settings of the currency; such as if someone were looking at a restaurant menu with currency amounts next to menu items.

toDecimalDigits : Currency -> Basics.Int

Get the number of decimal digits in a currency. of a currency from its code

The decimal digits is basically the size of the smaller unit the currency comes in. American dollars and Euros, for example, both have cents, and 100 cents make a dollar or Euro. So the decimal digits for these currencies is 2. Extreme cases include the Japanese Yen, which has 0, and Bitcoin, which has 8.

Search

search : String -> List Currency

Search all currencies by case-insensitive string matching on the name, symbol, and code.

searchCustom : String -> List Currency -> List Currency

Search through a list of currencies by case-insensitive string matching on the name, symbol, and code.