package safemoney

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Safemoney.QuotientSource

Sourceexception CurrencyTypeMismatch of string
Sourcetype t = {
  1. symbol_ : string;
    (*

    Currency Symbol

    *)
  2. value_ : Q.t;
    (*

    Value in Rational

    *)
}

Types

Type of quotient

Sourceval make_qv : (string * Q.t) -> t

Construction

make_qv name qv makes t with a currenc symbol and quotient value, e.g. make_qv "GBP" make_q("123456/100")

Sourceval show_sym : t -> unit

show_sym t print t's currency symbol

Sourceval show_val : t -> unit

show_val t prints t's currency value

Sourceval show_t : t -> unit

show_t t prints t's quotient value

Sourceval neg : t -> t

neg t negates t's quotient value

Sourceval abs : t -> t

abs t returns t's absolute quotient value

Sourceval (+) : t -> t -> t

t1 + t2 adds two t

Sourceval (-) : t -> t -> t

t1 - t2 substracts two t

Sourceval (*) : t -> Q.t -> t

t * qv multiplies a t with a plain rational value. Multiplying two quotient values does not make sense for currency ops

Sourceval (/) : t -> Q.t -> t

t / qv divides a t with a plain rational value. Dividing two quotient values does not make sense for currency ops

Sourceval to_json : t -> Yojson.Safe.t

to_json t converts t to json string

Sourceval to_sexp : t -> Base.Sexp.t

to_sexp t converts t to sexp