How the heck should we fix Ord for Array?
david.feuer at gmail.com
Fri Oct 2 00:37:07 UTC 2020
At present, the Eq instance for Data.Array.Array is somewhat
broken. In particular, it ignores the array bounds for empty arrays
(but not for other arrays), so its meaning is inconsistent, and the
bounds function doesn't respect ==. The fix to that is tiny and
obvious: pay attention to the bounds regardless.
Eq and Ord instances are expected to be compatible:
a == b <==> compare a b = EQ
So when I started putting together a merge request to fix the Eq
instance, I glanced over at the Ord instance to see what that was
doing. That instance was
1. Incompatible with the current Eq instance.
2. Incompatible with the proposed Eq instance.
Specifically, that instance compares the association lists of the two
arrays, ignoring the bounds in all cases.
It is not at all obvious to me what the Ord instance should actually
be, except that it should be compatible with Eq.
More information about the Libraries