3 ms·
> First, you can have a type-checker check the currency; that doesn't have to be a runtime error: > Money<Usd> m = …; > There will, of course, be instances whe
by AEVL 3y ago
> First, you can have a type-checker check the currency; that doesn't have to be a runtime error:
> Money<Usd> m = …;
> There will, of course, be instances where you must handle currency dynamically.
With dependent types, checking for currency validity may be handled at compile-time. (This is touched upon in the post linked in the comment you replied to.)
For the case of conversion between currencies of monetary amounts:
https://github.com/anderslundstedt/type-experiments#type-safe-currency-conversions https://github.com/anderslundstedt/type-experiments#type-saf...