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-cafeOnly members subscribed via the mailman list are allowed to post.