package base
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e89c4b898d9e93527f1c84f6784f9a92a1dfa86877f39ac4450a6cb69e866de6
md5=5a00382c724e97b6768aaa27481dd3cc
doc/base/Base/Comparator/index.html
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, 'b) comparator = ('a, 'b) tmodule 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)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 S_to_S1
(S : S) :
S1 with type 'a t = S.t with type comparator_witness = S.comparator_witnessMake creates a comparator value and its phantom comparator_witness type for a nullary type.
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 ... endDerived creates a comparator function that constructs a comparator for the type 'a t given a comparator for the type 'a.
module type Derived2 = sig ... endDerived2 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 ... endmodule Derived_phantom
(M : sig ... end) :
Derived_phantom with type ('a, 'b) t := ('a, 'b) M.tDerived_phantom creates a comparator function that constructs a comparator for the type ('a, 'b) t given a comparator for the type 'a.