Monetary Type
The monetary type stores a numeric amount with its currency, preventing accidental mixing of different currencies.
Architecture
Section titled “Architecture”Basic Usage
Section titled “Basic Usage”Arithmetic
Section titled “Arithmetic”Add or subtract values with the same currency:
Attempting to add different currencies raises an error:
Currency Functions
Section titled “Currency Functions”Get the currency for a country:
Get countries using a currency:
Parsing
Section titled “Parsing”The parser handles various formats:
Ambiguous symbols like $ require explicit currency codes: