Mimer implementation has Ord
instances not compatible with Eq
#7638
Labels
style
Haskell coding style (not in changelog)
Ord
instances not compatible with Eq
#7638
While reading the Mimer sources, I found with @oskeri that some
Ord
instances violate the laws ofOrd
, in particular this law:Source: https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-Ord.html#t:Ord
One instance violating this is
SearchBranch
:agda/src/full/Agda/Mimer/Mimer.hs
Lines 156 to 162 in 7b3b899
SearchBranch
es are organized in a prio-queue, e.g. here:agda/src/full/Agda/Mimer/Mimer.hs
Lines 817 to 819 in 7b3b899
This queue is 3rd party (package
pqueue
).The package docs do not state how these queues handle duplicates.
Looking at the source, duplicates seem to be allowed. However, there is no contract guaranteeing this, so future versions might deviate from the currently implemented behavior.
In general, it feels risky to have invalid Ord instances. At least, that puts the author in the obligation of giving arguments why such unlawful instances are ok. In the current code, there are no arguments written out. (There is just a "TODO: Explain").
Ord Component
also violates this law:agda/src/full/Agda/Mimer/Mimer.hs
Lines 199 to 215 in 7b3b899
The text was updated successfully, but these errors were encountered: