Batteries user guide : Batteries.Number

`sig
exception Overflow
exception NaN
type 'a numeric =
'a BatNumber.numeric = {
zero : 'a;
one : 'a;
neg : 'a -> 'a;
succ : 'a -> 'a;
pred : 'a -> 'a;
abs : 'a -> 'a;
add : 'a -> 'a -> 'a;
sub : 'a -> 'a -> 'a;
mul : 'a -> 'a -> 'a;
div : 'a -> 'a -> 'a;
modulo : 'a -> 'a -> 'a;
pow : 'a -> 'a -> 'a;
compare : 'a -> 'a -> int;
of_int : int -> 'a;
to_int : 'a -> int;
of_string : string -> 'a;
to_string : 'a -> string;
of_float : float -> 'a;
to_float : 'a -> float;
}
module type Infix =
sig
type bat__infix_t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
end
module type Compare =
sig
type bat__compare_t
val ( <> ) : bat__compare_t -> bat__compare_t -> bool
val ( >= ) : bat__compare_t -> bat__compare_t -> bool
val ( <= ) : bat__compare_t -> bat__compare_t -> bool
val ( > ) : bat__compare_t -> bat__compare_t -> bool
val ( < ) : bat__compare_t -> bat__compare_t -> bool
val ( = ) : bat__compare_t -> bat__compare_t -> bool
end
module type RefOps =
sig
type bat__refops_t
val ( += ) : bat__refops_t ref -> bat__refops_t -> unit
val ( -= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( *= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( /= ) : bat__refops_t ref -> bat__refops_t -> unit
end
module type Numeric =
sig
type t
val zero : t
val one : t
val neg : t -> t
val abs : t -> t
val add : t -> t -> t
val sub : t -> t -> t
val mul : t -> t -> t
val div : t -> t -> t
val modulo : t -> t -> t
val pow : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val ord : t BatOrd.ord
val of_int : int -> t
val to_int : t -> int
val of_float : float -> t
val to_float : t -> float
val of_string : string -> t
val to_string : t -> string
val operations : t numeric
type discrete = t
val succ : t -> t
val pred : t -> t
module Infix :
sig
type bat__infix_t = t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) :
bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
end
module Compare :
sig
type bat__compare_t = t
val ( <> ) : bat__compare_t -> bat__compare_t -> bool
val ( >= ) : bat__compare_t -> bat__compare_t -> bool
val ( <= ) : bat__compare_t -> bat__compare_t -> bool
val ( > ) : bat__compare_t -> bat__compare_t -> bool
val ( < ) : bat__compare_t -> bat__compare_t -> bool
val ( = ) : bat__compare_t -> bat__compare_t -> bool
end
type bat__infix_t = t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
type bat__refops_t = t
val ( += ) : bat__refops_t ref -> bat__refops_t -> unit
val ( -= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( *= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( /= ) : bat__refops_t ref -> bat__refops_t -> unit
end
module type Bounded =
sig type bounded val min_num : bounded val max_num : bounded end
module type Discrete =
sig
type discrete
val to_int : discrete -> int
val succ : discrete -> discrete
val pred : discrete -> discrete
val ( -- ) : discrete -> discrete -> discrete BatEnum.t
val ( --- ) : discrete -> discrete -> discrete BatEnum.t
end
module type NUMERIC_BASE =
sig
type t
val zero : t
val one : t
val neg : t -> t
val succ : t -> t
val pred : t -> t
val abs : t -> t
val add : t -> t -> t
val sub : t -> t -> t
val mul : t -> t -> t
val div : t -> t -> t
val modulo : t -> t -> t
val pow : t -> t -> t
val compare : t -> t -> int
val of_int : int -> t
val to_int : t -> int
val of_string : string -> t
val to_string : t -> string
val of_float : float -> t
val to_float : t -> float
end
module MakeInfix :
functor (Base : NUMERIC_BASE) ->
sig
type bat__infix_t = Base.t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
end
module MakeCompare :
functor (Base : NUMERIC_BASE) ->
sig
type bat__compare_t = Base.t
val ( <> ) : bat__compare_t -> bat__compare_t -> bool
val ( >= ) : bat__compare_t -> bat__compare_t -> bool
val ( <= ) : bat__compare_t -> bat__compare_t -> bool
val ( > ) : bat__compare_t -> bat__compare_t -> bool
val ( < ) : bat__compare_t -> bat__compare_t -> bool
val ( = ) : bat__compare_t -> bat__compare_t -> bool
end
module MakeRefOps :
functor (Base : NUMERIC_BASE) ->
sig
type bat__refops_t = Base.t
val ( += ) : bat__refops_t ref -> bat__refops_t -> unit
val ( -= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( *= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( /= ) : bat__refops_t ref -> bat__refops_t -> unit
end
module MakeNumeric :
functor (Base : NUMERIC_BASE) ->
sig
type t = Base.t
val zero : t
val one : t
val neg : t -> t
val abs : t -> t
val add : t -> t -> t
val sub : t -> t -> t
val mul : t -> t -> t
val div : t -> t -> t
val modulo : t -> t -> t
val pow : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val ord : t BatOrd.ord
val of_int : int -> t
val to_int : t -> int
val of_float : float -> t
val to_float : t -> float
val of_string : string -> t
val to_string : t -> string
val operations : t numeric
type discrete = t
val succ : t -> t
val pred : t -> t
module Infix :
sig
type bat__infix_t = t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) :
bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) :
bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
end
module Compare :
sig
type bat__compare_t = t
val ( <> ) : bat__compare_t -> bat__compare_t -> bool
val ( >= ) : bat__compare_t -> bat__compare_t -> bool
val ( <= ) : bat__compare_t -> bat__compare_t -> bool
val ( > ) : bat__compare_t -> bat__compare_t -> bool
val ( < ) : bat__compare_t -> bat__compare_t -> bool
val ( = ) : bat__compare_t -> bat__compare_t -> bool
end
type bat__infix_t = t
val ( + ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( - ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( * ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( / ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( ** ) : bat__infix_t -> bat__infix_t -> bat__infix_t
val ( -- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
val ( --- ) : bat__infix_t -> bat__infix_t -> bat__infix_t BatEnum.t
type bat__refops_t = t
val ( += ) : bat__refops_t ref -> bat__refops_t -> unit
val ( -= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( *= ) : bat__refops_t ref -> bat__refops_t -> unit
val ( /= ) : bat__refops_t ref -> bat__refops_t -> unit
end
val generic_pow :
zero:'a ->
one:'a ->
div_two:('a -> 'a) ->
mod_two:('a -> 'a) -> mul:('a -> 'a -> 'a) -> 'a -> 'a -> 'a
end`