Arg has unlawful instances
David Feuer
david.feuer at gmail.com
Fri May 10 13:13:57 UTC 2019
Foldable, Traversable, Bifoldable, and Bitraversable instances of
Data.Semigroup.Arg don't respect ==.
For example, Arg () 1 == Arg () 2 = True, but sum (Arg () 1) = 1 and sum
(Arg () 2) = 2.
I believe the best solution is to remove the Traversable and Bitraversable
instances, and define
foldMap _ _ = mempty
bifoldMap f _ (Arg a _) = a
There also needs to be some documentation about the fact that the Arg
constructor allows inspection that does not respect Eq.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20190510/559e573b/attachment.html>
More information about the Libraries
mailing list