Module Base.Comparator
A type-indexed value that allows one to compare (and for generating error messages, serialize) values of the type in question.
One of the type parameters is a phantom parameter used to distinguish comparators potentially built on different comparison functions. In particular, we want to distinguish those using polymorphic compare from those using a monomorphic compare.
type ('a, 'witness) t= private{compare : 'a -> 'a -> int;sexp_of_t : 'a -> Sexp.t;}type ('a, 'b) comparator= ('a, 'b) t
module type S = sig ... endmodule type S1 = sig ... endmodule type S_fc = sig ... endval make : compare:('a -> 'a -> int) -> sexp_of_t:('a -> Sexp.t) -> (module S_fc with type comparable_t = 'a)makecreates 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 S_to_S1 : functor (S : S) -> S1 with type 'a t = S.t with type comparator_witness = S.comparator_witnessmodule Make : functor (M : sig ... end) -> S with type t := M.tMakecreates acomparatorvalue and its phantomcomparator_witnesstype for a nullary type.
module Make1 : functor (M : sig ... end) -> S1 with type 'a t := 'a M.tMake1creates acomparatorvalue and its phantomcomparator_witnesstype for a unary type. It takes acompareandsexp_of_tthat have non-standard types because theComparator.ttype doesn't allow passing in additional values for the type argument.
module type Derived = sig ... endmodule Derived : functor (M : sig ... end) -> Derived with type 'a t := 'a M.tDerivedcreates acomparatorfunction that constructs a comparator for the type'a tgiven a comparator for the type'a.
module type Derived2 = sig ... endmodule Derived2 : functor (M : sig ... end) -> Derived2 with type ('a, 'b) t := ('a, 'b) M.tDerived2creates acomparatorfunction that constructs a comparator for the type('a, 'b) tgiven comparators for the type'aand'b.
module type Derived_phantom = sig ... endmodule Derived_phantom : functor (M : sig ... end) -> Derived_phantom with type ('a, 'b) t := ('a, 'b) M.tDerived_phantomcreates acomparatorfunction that constructs a comparator for the type('a, 'b) tgiven a comparator for the type'a.