Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gregorias/safe-money
a prototype library for safe money representation
https://github.com/gregorias/safe-money
existential-types haskell type-safe
Last synced: about 1 month ago
JSON representation
a prototype library for safe money representation
- Host: GitHub
- URL: https://github.com/gregorias/safe-money
- Owner: gregorias
- License: agpl-3.0
- Created: 2023-07-23T15:54:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-06T20:45:11.000Z (about 1 year ago)
- Last Synced: 2023-11-07T18:23:51.607Z (about 1 year ago)
- Topics: existential-types, haskell, type-safe
- Language: Haskell
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-money
This is an experimental Haskell library that explores creating a safe type for
representing monetary amounts.I set up the following requirements:
1. The type should allow declaring the number of fractional digits.
2. The type should allow declaring the amount's currency and prevent operations
on monetary amounts of differring currencies.
3. Currency should only allow valid currencies.## Unsolved problems
```haskell
-- Can I do not forgetful currency to witness cast?
currencyToWitness :: (c :: Currency) -> CurrencyWitness c
-- The above doesn't work, because (c :: Currency) says that currencyToWitness
-- accepts a paramater of type c, which is a value (of type Currency), so it
-- doesn't work.
```## See also
- [How do I efficiently add existentially typed safe money values?](https://stackoverflow.com/questions/77429592/how-do-i-efficiently-add-existentially-typed-safe-money-values)