package safemoney

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

Parameters

module Qv : Qv_intf.S

Signature

exception CurrencyTypeMismatch of string
type t = {
  1. symbol : string;
    (*

    Currency Symbol

    *)
  2. value : Qv.t;
    (*

    Value in Rational

    *)
}

Types

include Ppx_compare_lib.Comparable.S with type t := t
val compare : t -> t -> int
type showable = {
  1. symbol_ : string;
  2. value_ : string;
}

showable for t

val pp_showable : Ppx_deriving_runtime.Format.formatter -> showable -> Ppx_deriving_runtime.unit
val show_showable : showable -> Ppx_deriving_runtime.string
val showable_to_yojson : showable -> Yojson.Safe.t
val sexp_of_showable : showable -> Sexplib0.Sexp.t
val showable_of_sexp : Sexplib0.Sexp.t -> showable
val make_qv : (string * Qv.t) -> t

Construction

Construct quotient value, e.g. make_qv "GBP" Utils.make_q("123456/100")

val show_sym : t -> unit

Print the currency symbol

val show_val : t -> unit

Print the currency value

val show_t : t -> unit

Print the quotient value

val neg : t -> t

Negate a quotient value

val abs : t -> t

Return an absolute quotient value

val (+) : t -> t -> t

Add two quotient values with same symbol as required

val (-) : t -> t -> t

Substract two quotient values with same symbol as required

val (*) : t:t -> value:Qv.t -> t

Multiply a quotient value with a plain rational value. Multiplying two quotient values does not make sense for currency ops.

val (/) : t -> Qv.t -> t

Divide a quotient value with a plain rational value. Dividing two quotient values does not make sense for currency ops.

val to_showable_json : t -> string

Convert t to showable rep