Module Comparer.Counterfeit

Counterfeit takes a compare function and type and yields a comparer that asserts that the given compare type is a singleton for the given compare function. This is not checked by the type system. It is the client's responsibility to ensure that distinct types are provided for distinct compare functions. If the same type is used for multiple functions, then Counterfeit will produce type-compatible comparers even though the wrapped compare functions differ.

Parameters

module Ord : sig ... end

Signature

type ('a, 'compare_a) comparer := ('a, 'compare_a) t
type t = Ord.t
type compare = Ord.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