base

Full standard library replacement for OCaml
IN THIS PACKAGE
type ('a, 'witness) t = private {
compare : 'a -> 'a -> int;
sexp_of_t : 'a -> Sexp.t;
}

('a, 'witness) t contains a comparison function for values of type 'a. Two values of type t with the same 'witness are guaranteed to have the same comparison function.

type ('a, 'b) comparator = ( 'a, 'b ) t
module type S = sig ... end
module type S1 = sig ... end
module type S_fc = sig ... end
val make : compare:( 'a -> 'a -> int ) -> sexp_of_t:( 'a -> Sexp.t ) -> (module S_fc with type comparable_t = 'a)

make creates a comparator witness for the given comparison. It is intended as a lightweight alternative to the functors below, to be used like so:

include (val Comparator.make ~compare ~sexp_of_t)
module Poly : S1 with type 'a t = 'a
module Module : sig ... end
module S_to_S1 (S : S) : S1 with type 'a t = S.t with type comparator_witness = S.comparator_witness
module Make (M : sig ... end) : S with type t := M.t

Make creates a comparator value and its phantom comparator_witness type for a nullary type.

module Make1 (M : sig ... end) : S1 with type 'a t := 'a M.t

Make1 creates a comparator value and its phantom comparator_witness type for a unary type. It takes a compare and sexp_of_t that have non-standard types because the Comparator.t type doesn't allow passing in additional values for the type argument.

module type Derived = sig ... end
module Derived (M : sig ... end) : Derived with type 'a t := 'a M.t

Derived creates a comparator function that constructs a comparator for the type 'a t given a comparator for the type 'a.

module type Derived2 = sig ... end
module Derived2 (M : sig ... end) : Derived2 with type ('a, 'b) t := ( 'a, 'b ) M.t

Derived2 creates a comparator function that constructs a comparator for the type ('a, 'b) t given comparators for the type 'a and 'b.

module type Derived_phantom = sig ... end
module Derived_phantom (M : sig ... end) : Derived_phantom with type ('a, 'b) t := ( 'a, 'b ) M.t

Derived_phantom creates a comparator function that constructs a comparator for the type ('a, 'b) t given a comparator for the type 'a.