Up

module Number

: sig
#
module type Spec = sig

Specification of general number properties

#
type t
include Core.Std.Interfaces.Comparable with type t := t
include Core.Std.Interfaces.Floatable with type t := t
include Core.Std.Hashable.S_binable with type t := t
include Core.Std.Interfaces.Sexpable with type t := t
include Core.Std.Interfaces.Stringable with type t := t
include Core.Std.Interfaces.Binable with type t := t
end
#
module type Verified_spec = sig

Specification of numbers with constraint checks

include Spec
#
val check : t -> (unit, string) Core.Std.Result.t
end
#
module type S = sig

Signature of numbers that have a verified (t) and unverified (repr) representation and a function to verify the latter.

include Spec
#
type repr
#
val verify : repr -> t
end
#
module type S0 = sig

Signature of numbers that also have a zero

include S
#
val zero : t
end
#
module Make_verified : functor (Spec : Verified_spec) -> S with type repr = Spec.t and type t = private Spec.t

Functor for making constrained numbers from specifications. This functor enforces the invariant through a private type.

#
module Make_verified_unsafe : functor (Spec : Verified_spec) -> S with type repr = Spec.t and type t = Spec.t

Same as Make_verified, but does not enforce invariants. Useful for extending verified numbers with more features before "sealing" the type with a private declaration.

#
module type Verified_std_spec = sig

Specification used for standard numbers (Int.t, Int32.t, Int63.t Int64.t, Nativeint.t, Float.t) to enrich them with Pos.t, Pos0.t, Neg.t, and Neg0.t modules, and the Make_bounded and Make_bounded_unsafe functors.

include Spec
#
val module_name : string
#
val zero : t
end
#
module type Verified_std = sig

Signature of standard numbers (Int.t, Int32.t, Int63.t Int64.t, Nativeint.t, Float.t) to enrich them with Pos.t, Pos0.t, Neg.t, and Neg0.t modules, and the Make_bounded and Make_bounded_unsafe functors.

#
type repr
#
module type S = S with type repr = repr

Abbreviations

#
module type S0 = S0 with type repr = repr
#
module Pos : S with type t = private repr

Positive and negative numbers with and without zero.

#
module Pos0 : S0 with type t = private repr
#
module Neg : S with type t = private repr
#
module Neg0 : S0 with type t = private repr
#
module type Bounded_spec = sig

Specification of bounded numbers

#
val name : string
#
val lower : repr
#
val upper : repr
end
#
module type Bounded = sig

Signature of bounded numbers

include Bounded_spec
include S
end
#
module Make_bounded : functor (Spec : Bounded_spec) -> Bounded with type t = private repr

Functor of creating bounded numbers

Unsafe modules and functors that still fully expose the representation for extensibility.

#
module Pos_unsafe : S with type t = repr
#
module Pos0_unsafe : S0 with type t = repr
#
module Neg_unsafe : S with type t = repr
#
module Neg0_unsafe : S0 with type t = repr
#
module Make_bounded_unsafe : functor (Spec : Bounded_spec) -> Bounded with type t = repr
end
#
module Make_verified_std : functor (Spec : Verified_std_spec) -> Verified_std with type repr = Spec.t

Functor for enriching standard numbers (Int.t, Int32.t, Int63.t Int64.t, Nativeint.t, Float.t) with Pos.t, Pos0.t, Neg.t, and Neg0.t modules, and the Make_bounded and Make_bounded_unsafe functors.

end