| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Data.Currency
Description
Currency names, symbols and codes. Reference: - https://www.xe.com/symbols - https://www.xe.com/currency
Synopsis
- type CurrencyCode = Text
- type CurrencySymbol = Text
- currencies :: [([Char], CurrencyCode, CurrencySymbol)]
- cryptocurrencies :: [CurrencyCode]
- currencySymbolToCode :: CurrencySymbol -> Maybe CurrencyCode
- currencyCodeToSymbol :: CurrencyCode -> Maybe CurrencySymbol
- toCurrencyCode :: CurrencySymbol -> CurrencyCode
Documentation
type CurrencyCode = Text Source #
An ISO 4217 currency code, like EUR. Generally used for fiat currencies, but may also use the X* convention for non-country currencies (eg XAU, XBT), or ISO 20022 cryptocurrency codes (eg ADA).
type CurrencySymbol = Text Source #
A traditional currency symbol like $ or ¥ (as opposed to a currency code like USD or JPY). Usually one character, sometimes more, like C$ or BZ$.
currencies :: [([Char], CurrencyCode, CurrencySymbol)] Source #
cryptocurrencies :: [CurrencyCode] Source #
The top 100 cryptocurrencies by market capitalisation, as ticker symbols, in descending rank order. Snapshot taken from the CoinGecko public API on 2026-04-30: https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1
currencySymbolToCode :: CurrencySymbol -> Maybe CurrencyCode Source #
Look for a currency code corresponding to this currency symbol.
>>>currencySymbolToCode ""Nothing>>>currencySymbolToCode "$"Just "USD"
currencyCodeToSymbol :: CurrencyCode -> Maybe CurrencySymbol Source #
Look for a currency symbol corresponding to this currency code.
>>>currencyCodeToSymbol "CZK" -- Just "Kč"Just "K\269"
toCurrencyCode :: CurrencySymbol -> CurrencyCode Source #
Like currencySymbolToCode, but return the input unchanged if no ISO
code is known. Useful for normalising free-form commodity labels: known
currency symbols become ISO codes, while tickers/abbreviations pass through.
>>>toCurrencyCode "$""USD">>>toCurrencyCode "BTC""BTC"