How the heck should we fix Ord for Array?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How the heck should we fix Ord for Array?

David Feuer
At present, the Eq instance for Data.Array.Array is somewhat
broken[1]. 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.

[1] https://gitlab.haskell.org/ghc/ghc/-/issues/18700
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries