Monoid over XOR or XNOR, and Monoid lifted by Applicative.

Matthew Farkas-Dyck m.farkasdyck at gmail.com
Sat May 5 20:54:55 UTC 2018


On 5/5/18, Edward Kmett <ekmett at gmail.com> wrote:
> In that same light, we're also missing packaged monoids for the bitwise
> (.|.), (.&.), xor (and the non-existent xnor) from Data.Bits.

I defined a `BitSet` type in my alg package:
http://hackage.haskell.org/package/alg
(Building docs failed, so here is the definition: `newtype BitSet a =
BitSet { bits :: a }`)

The `Monoid` instance is (`False`, `xor`) (wasn't thinking about xnor,
stupid me).

I was also trying to define `Monoid` instances for `Min (BitSet a)`
and `Max (BitSet a)` but alas, they overlap, tho `BitSet` is not `Ord`
(so usual instances are useless).

Maybe we want a `Lattice` class?


More information about the Libraries mailing list