To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
Defines functors for making modules comparable.
module Foo = struct module T = struct type t = ... [@@deriving compare, sexp] end include T include Comparable.Make (T) end
Comparable.S in the signature
module Foo : sig type t = ... include Comparable.S with type t := t end
To add an
module C = Comparable.Make (T) include C module Infix = (C : Comparable.Infix with type t := t)
A common pattern is to define a module
O with a restricted signature. It aims to be (locally) opened to bring useful operators into scope without shadowing unexpected variable names. E.g., in the
module O = struct include (C : Comparable.Infix with type t := t) let to_string t = .. end
Date would shadow
now, but opening
let now = .. in let someday = .. in Date.O.(now > someday)
module type Infix = Comparisons.Infix
module type S = sig ... end
module type Polymorphic_compare = Comparisons.S
module type With_compare = sig ... end
Various combinators for
module type With_zero = sig ... end
lexicographic cmps x y compares
y lexicographically using functions in the list
lift cmp ~f x y compares
y by comparing
f x and
f y via
reverse cmp x y = cmp y x
Reverses the direction of asymmetric relations by swapping their arguments. Useful, e.g., for relations implementing "is a subset of" or "is a descendant of".
Where reversed relations are already provided, use them directly. For example,
descending, which are more readable as a pair than
reverse compare. Similarly,
<= is more idiomatic than
The functions below are analogues of the type-specific functions exported by the
Polymorphic_compare functions from just
[@@deriving compare], without need for the
sexp_of_t required by
Make* (see below).
module Polymorphic_compare (T : sig ... end) : Polymorphic_compare with type t := T.t
Inherit comparability from a component.
module Make_using_comparator (T : sig ... end) : S with type t := T.t with type comparator_witness := T.comparator_witness