Std.Money
Std.Money — currency-typed Money on `Std.Decimal` (Layer 3 Sky source).
Types
type Currency = USD | EUR | GBP | JPY | CHF | AUD | CAD | NZD | SEK | NOK | DKK | CNY | HKD | SGD | KRW | TWD | INR | THB | MYR | IDR | PHP | VND | BRL | MXN | ARS | CLP | ZAR | TRY | RUB | UAH | PLN | CZK | HUF | RON | BGN | AED | SAR | QAR | KWD | BHD | OMR | JOD | ILS | EGP | NGN | KES | GHS | MAD | TND | DZD | PKR | BDT | LKR | NPR | BTC | ETH | USDT | USDC | CurrencyRaw String
type Money = Money Decimal Currency
type Rates
Values
abs : Money -> Moneyadd : Money -> Money -> Result Error Money
The sum of two Money values. Two currencies are an `Err` naming both
addPercent : Decimal -> Money -> Moneyallocate : Int -> Money -> List Money
Allocate a Money value across N parts as evenly as possible,
amount : Money -> Decimalcompare : Money -> Money -> Result Error Int
The order of two amounts in one currency: `-1`, `0` or `1`. Two
convert : Rates -> Currency -> Money -> Result Error Money
Convert Money to `to` with a rate from `fx`. The same currency is
currency : Money -> CurrencycurrencyCode : Currency -> String
The code of a currency, in upper case (`CurrencyRaw "gbp"` is `"GBP"`).
currencyFromCode : String -> Maybe Currency
The Currency of an ISO 4217 code, or `Nothing` for text that is not a
currencyName : Currency -> Stringeq : Money -> Money -> Bool
Equal amount AND equal currency. The one combining operation that is
eqCurrency : Currency -> Currency -> Bool
Two currencies are the same when their codes are, in upper case:
format : Money -> String
Default symbol-prefixed form: "$12.34", "¥1234" (JPY).
formatWithCode : Money -> String
ISO-code suffix form: "12.34 USD". Preferred for B2B.
fromMajor : Currency -> Int -> MoneyfromMinor : Currency -> Int -> MoneyfromString : Currency -> String -> Result Error Moneygt : Money -> Money -> Result Error Bool
`a > b` in one currency; an `Err` for two currencies.
gte : Money -> Money -> Result Error Bool
`a >= b` in one currency; an `Err` for two currencies.
isNegative : Money -> BoolisPositive : Money -> BoolisZero : Money -> Boollt : Money -> Money -> Result Error Bool
`a < b` in one currency; an `Err` for two currencies.
lte : Money -> Money -> Result Error Bool
`a <= b` in one currency; an `Err` for two currencies.
minorUnits : Currency -> Intmul : Decimal -> Money -> Money
Multiply by a scalar (Decimal). Currency carries through.
neg : Money -> Moneyneq : Money -> Money -> Bool
`not (eq a b)`: `True` for two different currencies.
percentOf : Decimal -> Money -> Moneyrate : Currency -> Currency -> Rates -> Maybe Decimal
The rate from one currency to another: `Just 1` for the same currency,
rates : List ( Currency, Currency, Decimal ) -> Rates
A rate table from `( from, to, rate )` triples: one unit of `from` is
sub : Money -> Money -> Result Error Money
`a` minus `b`. Two currencies are an `Err`, as `add`.
subPercent : Decimal -> Money -> Moneysum : Currency -> List Money -> Result Error Money
The sum of a list of Money values in `c` (`zero c` for an empty list). A
symbol : Currency -> StringtoMinor : Money -> Int
The amount in minor units (cents for USD). An amount whose minor units
zero : Currency -> Money