Monomorphic comparison for common ground types and common type constructors.
Compare provides a module signature for the standard comparison functions and operators as well as modules of that signature for the common OCaml ground types (
bool, etc.) and type constructors (
Compare also provides some additional helpers for comparison-related tasks.
Signatures and a functor
module type COMPARABLE = sig ... end
module type S = sig ... end
S is a signature for a fully-fledge comparison module. It includes all the functions and operators derived from a
The specialised comparison and all the specialised functions and operators on the base types are compatible with the polymorphic comparison and all the polymorphic functions and operators from the
module Int : sig ... end
Int is a comparison module. Out of performance concerns, the signature actually contains compiler builtins (
external) rather than
Provided the functor argument(s) are compatible with the polymorphic comparison of the
Stdlib, then the specialised comparison and all the specialised functions and operators on the derived types are compatible with the polymorphic comparison and all the polymorphic functions and operators from the
module Result (Ok : COMPARABLE) (Error : COMPARABLE) : S with type t = (Ok.t, Error.t) result
Helpers for more readable
These modules are intended to be used as
Module.(expression), most often within an
if condition. E.g.,
if Compare.List_length_with.(chunks > max_number_of_chunks) then raise Maximum_size_exceeeded else ..
module List_length_with : sig ... end
module List_lengths : sig ... end