keen/compare

Source
This is a standard module and does not need to be explicitly imported.

Functions for comparison.

If you want a type to be comparable, just define == and <=>. Use the signatures defined in the compare spec.

Other functions like != are defined here, derived from those.

comparison enum
less
equal
greater

Result of comparison.

If a <=> b is equal, then any function on a should return ths same result as a on b.

== bool(a comparison, b comparison)
to symbol(a comparison)
equal[t] spec
== bool(a t, b t)
compare[t] spec t equal
<=> comparison(a t, b t)
When defined for mutable values, this should compare their content without regard to mutablility; so it may consider values equal that may not be equal in the future.
- comparison(a comparison)
Opposite comparison
!=[t] bool(a t, b t) t equal
True iff !(a == b).
<[t] bool(a t, b t) t compare
True iff (a <=> b) == comparison.
<=[t] bool(a t, b t) t compare
True iff (a <=> b) != comparison.
>[t] bool(a t, b t) t compare
True iff (a <=> b) == comparison.
>=[t] bool(a t, b t) t compare
True iff (a <=> b) != comparison.
min[t] t(a t, b t) t compare
Returns the lesser argument. Returns b if they are equal.
max[t] t(a t, b t) t compare
Returns the greater argument. Returns b if they are equal.
compare-reverse[t] record
inner t
Wraps a value and reverses comparison (so less becomes greater and vice versa)
==[t] bool(a t compare-reverse, b t compare-reverse) t equal
<=>[t] comparison(a t compare-reverse, b t compare-reverse) t compare