https://github.com/alx741/currencies
ISO 4217 Currencies representation, pretty printing and conversion.
https://github.com/alx741/currencies
currencies haskell library money
Last synced: 8 months ago
JSON representation
ISO 4217 Currencies representation, pretty printing and conversion.
- Host: GitHub
- URL: https://github.com/alx741/currencies
- Owner: alx741
- License: bsd-3-clause
- Created: 2017-08-18T22:46:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T06:05:34.000Z (about 2 years ago)
- Last Synced: 2024-10-30T02:47:52.338Z (over 1 year ago)
- Topics: currencies, haskell, library, money
- Language: Haskell
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://circleci.com/gh/alx741/currencies)
# currencies
ISO 4217 Currencies representation, pretty printing and conversion:
* Represent monetary amounts of a particular currency in a type-safe manner
* Convert amounts between different currencies
* Print human readable amounts
```haskell
prettyPrint (Amount USD 2342.2)
-- "USD 2,342.20"
prettyPrint (Amount EUR 45827.346)
-- "EUR 45,827.35"
prettyPrintWith (defaultConfig { useCurrencySymbol = True }) (Amount USD 2342.2)
-- "$ 2,342.20"
prettyPrintWith (defaultConfig { useCurrencySymbol = True }) (Amount EUR 2342.2)
-- "€ 2,342.20"
prettyPrintWith (defaultConfig { showDecimals = False }) (Amount USD 25.50)
-- "USD 25"
convert USD (Amount EUR 23482.34)
-- Amount USD 27709.1612
prettyPrint $ convert USD (Amount EUR 23482.34)
-- "USD 27,709.16"
compareAmounts (Amount EUR 1000) (Amount BTC 1) -- Compare to Bitcoin
-- LT
```