
29 Sep
2020
29 Sep
'20
5:33 a.m.
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