All the worlds currencies as records and union types, with helper functions too.
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" == NothingGet 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.
Get the name of a currency from its code
toName EUR { plural = True } == "euros"
toName ALL { plural = False } == "Albanian Lek"
toName ALL { plural = True } == "Albanian lekë"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.
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.
This type represents all the possible currencies as currency codes.