Module Core_kernel.Comparable

module type Infix = Core_kernel__.Comparable_intf.Infix
module type Map_and_set_binable = Core_kernel__.Comparable_intf.Map_and_set_binable
module type S_plain = Core_kernel__.Comparable_intf.S_plain
module type S = Core_kernel__.Comparable_intf.S
module type S_binable = Core_kernel__.Comparable_intf.S_binable
module type S_common = Core_kernel__.Comparable_intf.S_common
module type Validate = Core_kernel__.Comparable_intf.Validate
module type With_zero = Core_kernel__.Comparable_intf.With_zero
val lexicographic : ('a ‑> 'a ‑> int) list ‑> 'a ‑> 'a ‑> int

lexicographic cmps x y compares x and y lexicographically using functions in the list cmps.

val lift : ('a ‑> 'a ‑> 'int_or_bool) ‑> f:('b ‑> 'a) ‑> 'b ‑> 'b ‑> 'int_or_bool

lift cmp ~f x y compares x and y by comparing f x and f y via cmp.

module Inherit : functor (C : sig ... end) -> functor (T : sig ... end) -> S with type t := T.t

Inherit comparability from a component.

Usage example:


      module Foo = struct
        module T = struct
          type t = ... [@@deriving compare, sexp]
        end
        include T
        include Comparable.Make (T)
      end
    

Then include Comparable.S in the signature (see comparable_intf.mli for an example).

To add an Infix submodule:


      module C = Comparable.Make (T)
      include C
      module Infix = (C : Comparable.Infix with type t := t)
    

Common pattern: 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 Date module:


      module O = struct
        include (C : Comparable.Infix with type t := t)
        let to_string t = ..
      end
    

Opening Date would shadow now, but opening Date.O doesn't:


      let now = .. in
      let someday = .. in
      Date.O.(now > someday)
    
module Make_plain : functor (T : sig ... end) -> S_plain with type t := T.t
module Make : functor (T : sig ... end) -> S with type t := T.t
module Make_plain_using_comparator : functor (T : sig ... end) -> S_plain with type t := T.t with type comparator_witness := T.comparator_witness
module Make_using_comparator : functor (T : sig ... end) -> S with type t := T.t with type comparator_witness := T.comparator_witness
module Make_binable : functor (T : sig ... end) -> S_binable with type t := T.t
module Make_binable_using_comparator : functor (T : sig ... end) -> S_binable with type t := T.t with type comparator_witness := T.comparator_witness
module Extend : functor (M : Base.Comparable.S) -> functor (X : sig ... end) -> S with type t := M.t with type comparator_witness := M.comparator_witness
module Extend_binable : functor (M : Base.Comparable.S) -> functor (X : sig ... end) -> S_binable with type t := M.t with type comparator_witness := M.comparator_witness
module Map_and_set_binable : functor (T : sig ... end) -> Map_and_set_binable with type t := T.t
module Map_and_set_binable_using_comparator : functor (T : sig ... end) -> Map_and_set_binable with type t := T.t with type comparator_witness := T.comparator_witness
module Poly : functor (T : sig ... end) -> S with type t := T.t
module Validate : functor (T : sig ... end) -> Validate with type t := T.t
module With_zero : functor (T : sig ... end) -> With_zero with type t := T.t
module Validate_with_zero : functor (T : sig ... end) -> sig ... end
module Stable : sig ... end

The following module types and functors may be used to define stable modules