From 78a530cceef74df00ccc3d66f2c09cd4da241e4e Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 6 Jun 2021 17:15:51 -0400 Subject: [PATCH] feat(ord): add `poly`, deprecate `compare` --- src/core/CCOrd.mli | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/CCOrd.mli b/src/core/CCOrd.mli index 7b121a49..e2f9454d 100644 --- a/src/core/CCOrd.mli +++ b/src/core/CCOrd.mli @@ -6,11 +6,21 @@ type 'a t = 'a -> 'a -> int (** Comparison (total ordering) between two elements, that returns an int. *) +val poly : 'a t +(** Polymorphic "magic" comparison. Use with care, as it will fail on + some types. + @since NEXT_RELEASE *) + val compare : 'a t -(** Polymorphic "magic" comparison. *) +[@@deprecated "use CCOrd.poly instead, this name is too general"] +(** Polymorphic "magic" comparison. + @deprecated since NEXT_RELEASE in favor of {!poly}. The reason is that + [compare] is easily shadowed, can shadow other comparators, and is just + generally not very descriptive. *) val opp : 'a t -> 'a t -(** Opposite order. *) +(** Opposite order. For example, [opp a b < 0] iff [opp b a > 0]. + This can be used to sort values in the opposite order, among other things. *) val equiv : int -> int -> bool (** Returns [true] iff the two comparison results are the same. *)