123456789101112131415161718192021222324252627282930313233343536(** [Ord] defines primitives for {{:https://en.wikipedia.org/wiki/Total_order}
total order} over type [t]
In order for a module to implement [Ord], it has to conform to the {!T}
signature, which implies conformance to {!Ord.T} *)(** [Ord] implementation signature *)moduletypeTrait=sigtypet(* Type being compared *)valcmp:t->t->Ordering.t(** Returns ordering between two values of [t], left to right *)end(** Signature that defines [Ord] conformity *)moduletypeT=sigincludeEq.TmoduleOrd:Traitend(** Defines a default implementation of {!Trait} over an existing
{!PartialOrd.Trait} definition *)moduleMake(T:Partial_ord.Trait)=structtypet=T.tletcmptrhs=matchT.partial_cmptrhswith|Someordering->ordering|None->failwith"unexpected"end(** Compares values [x] and [y] with module [M] and returns an ordering, left to
right *)letcmp(typea)(moduleM:TwithtypeOrd.t=a)(x:a)(y:a)=M.Ord.cmpxy