Module Support.Ord

Totally ordered types.

module type ORD = sig ... end

Module type for totally ordered types.

module Make (T : sig ... end) : ORD with type t = T.t

Functor building an implementation of ORD given a type with a total comparator.

module Reverse (Ord : ORD) : ORD with type t = Ord.t

Functor building an implementation of ORD whose ordering is the reverse of the given totally ordered type.

val make : ('t -> 't -> int) -> (module ORD with type t = 't)

make compare is equivalent to the functor Make (T) with T.compare = compare.

val contramap : (module ORD with type t = 's) -> ('t -> 's) -> (module ORD with type t = 't)

If val f : 't -> 's, then contramap ord f is an instance of ORD for values of type 't by the ORD instance ord for values of type 's.

val sequence : (module ORD with type t = 's1) -> (module ORD with type t = 's2) -> ('t -> 's1) -> ('t -> 's2) -> (module ORD with type t = 't)

If val f1 : 't -> 's1 and val f2 : 't -> 's2, then sequence ord1 ord2 f1 f2 is an instance of ORD for values of type 't whose ordering is first ordered by contramapping by ord1 and f1, and if that ordering is equal then ordered by contramapping by ord2 and f2.

val sequence3 : (module ORD with type t = 's1) -> (module ORD with type t = 's2) -> (module ORD with type t = 's3) -> ('t -> 's1) -> ('t -> 's2) -> ('t -> 's3) -> (module ORD with type t = 't)

If val f1 : 't -> 's1, val f2 : 't -> 's2 and val f3 : 't -> 's3, then sequence ord1 ord2 ord3 f1 f2 f3 is an instance of ORD for values of type 't whose ordering is ordered in sequence by:

  • contramapping by ord1 and f1,
  • contramapping by ord2 and f2,
  • contramapping by ord3 and f3.