Module Comparer.Make

Make takes a compare function, mints a fresh compare type to act as a singleton type denoting that one compare function, and returns the compare function at a type stamped with its singleton type. In this way, Make applied to two different compare functions for the same type of values yields comparers with incompatible types.

Parameters

module Ord : sig ... end

Signature

type ('a, 'compare_a) comparer := ('a, 'compare_a) t
type t = Ord.t
type compare

compare types are equipped with functions to support use of @@deriving compare, equal, sexp on types parameterized by such singleton types for compare functions. These derived functions are never actually called, since the compare type parameters are phantom.

val compare_compare : compare -> compare -> int
val equal_compare : compare -> compare -> bool
val sexp_of_compare : compare -> Sexplib0.Sexp.t
val compare_of_sexp : Sexplib0.Sexp.t -> compare
val comparer : (t, compare) comparer