MINIMAL XOR (Was: Proposal: Make Eq type class single method)

Viktor Dukhovni ietf-dane at dukhovni.org
Wed Oct 27 15:32:40 UTC 2021


On Wed, Oct 27, 2021 at 11:14:45AM -0400, Carter Schonwald wrote:
> not necessarily ... there could be  contradictory sets of methods! :)
> 
> like the minimal sets for Field type class,  the xor would be for defining
> '/' in terms of reciprocal and times or vice versa (/ vs recip) and
> likewise (negate vs minus) etc etc

Logically redundant definitions aren't always redundant in practice if
one considers performance, floating point accuracy or even sometimes
divergence.

      For example, foldl on infinite snoc lists is not definable in
      terms of foldr which diverges, though admittedly I rather think
      that infinite snoc lists violate all reasonable expectations of
      a Foldable instance.

So in many cases redundancy warnings would not be viable.  The Eq
situation is likely more the exception that the rule.

The SQL NULL instances that are False for both "==" and "/=" look
like they could be a mistake to me, but presumably they work out
OK in practice, and I would expect that e.g. the relevant `Ord`
instances do return `EQ` for `compare Null Null`...  Less clear
is whether the non-lawful Eq defintion is in some predicably useful
way essential.

-- 
    Viktor.


More information about the Libraries mailing list