NS.ComparerSingleton types for compare functions
A comparer ('a, 'compare_a) t for type 'a is a "compare" function of type 'a -> 'a -> int tagged with a phantom type 'compare_a acting as a singleton type denoting an individual compare function.
module type S = sig ... endMake 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.
module Counterfeit
(Ord : sig ... end) :
S with type t = Ord.t with type compare = Ord.compareCounterfeit 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.
Apply (F) (A) takes a type ('a, 'compare_a) F.t with a type parameter 'a and a compare type 'compare_a for 'a, and a comparer A, and creates a comparer for F.t with 'a instantiated to A.t.
module type S1 = sig ... end