← all modules

Std.Money

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 -> Money
  add : Money -> Money -> Result Error Money
      The sum of two Money values. Two currencies are an `Err` naming both
  addPercent : Decimal -> Money -> Money
  allocate : Int -> Money -> List Money
      Allocate a Money value across N parts as evenly as possible,
  amount : Money -> Decimal
  compare : 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 -> Currency
  currencyCode : 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 -> String
  eq : 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 -> Money
  fromMinor : Currency -> Int -> Money
  fromString : Currency -> String -> Result Error Money
  gt : 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 -> Bool
  isPositive : Money -> Bool
  isZero : Money -> Bool
  lt : 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 -> Int
  mul : Decimal -> Money -> Money
      Multiply by a scalar (Decimal). Currency carries through.
  neg : Money -> Money
  neq : Money -> Money -> Bool
      `not (eq a b)`: `True` for two different currencies.
  percentOf : Decimal -> Money -> Money
  rate : 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 -> Money
  sum : 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 -> String
  toMinor : Money -> Int
      The amount in minor units (cents for USD). An amount whose minor units
  zero : Currency -> Money