Not only that, `xor` has inverses so it forms an abelian group

Regards, Andrew

On 29 Sep 2020, at 10:41, Andrew Butterfield <Andrew.Butterfield@scss.tcd.ie> wrote:

Hmmm - I thought so at first

A B A `xor` B
0 0      0
0 1      1
1 0      1
1 1      0

0 `xor` b = b
a `xor` 0 = a

Looks like 0 is the identity to me.

Regards, Andrew

On 29 Sep 2020, at 10:33, Ben Franksen <ben.franksen@online.de> wrote:

Am 29.09.20 um 10:27 schrieb Mario Lang:
instance Monoid QuadBitboard where
 mempty = QBB 0 0 0 0

-- | bitwise XOR
instance Semigroup QuadBitboard where
 QBB b0 b1 b2 b3 <> QBB b0' b1' b2' b3' =
   QBB (b0 `xor` b0') (b1 `xor` b1') (b2 `xor` b2') (b3 `xor` b3')

But maybe I am violating some laws

The Semigroup is okay, since 'xor' is indeed associative, and your
instance basically lifts it to 4-tuples.

The Monoid instance is wrong, though. There is no unit for 'xor'!

Cheers
Ben

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

--------------------------------------------------------------------
Andrew Butterfield     Tel: +353-1-896-2517     Fax: +353-1-677-2204
Lero@TCD, Head of Software Foundations & Verification Research Group
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
                         http://www.scss.tcd.ie/Andrew.Butterfield/
--------------------------------------------------------------------

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

--------------------------------------------------------------------
Andrew Butterfield     Tel: +353-1-896-2517     Fax: +353-1-677-2204
Lero@TCD, Head of Software Foundations & Verification Research Group
School of Computer Science and Statistics,
Room G.39, O'Reilly Institute, Trinity College, University of Dublin
                         http://www.scss.tcd.ie/Andrew.Butterfield/
--------------------------------------------------------------------