<html><head><style>p{margin-top:0px;margin-bottom:0px;}</style></head><body><div style="font-size:10pt; font-family:NanumGothic, ë‚˜ëˆ”고딕, sans-serif;"><p>Logical XOR is associative, also is XNOR. And they both have an identity element.</p><p> </p><p>Hence:</p><p> </p><p>newtype Even = Even {getEven :: Bool} </p><p>newtype Odd = Odd {getOdd :: Bool}</p><p> </p><p>instance Semigroup Even where</p><p>    (<>) = (==) -- (==) over Bool == Logical XNOR </p><p> </p><p>instance Semigroup Odd where</p><p>    (<>) = (/=) -- (/=) over Bool == Logical XOR </p><p> </p><p>instance Monoid Even where</p><p>    mempty = True</p><p> </p><p>instance Monoid Odd where</p><p>    mempty = False</p><p> </p><p>So foldMap would determine the parity of the number of Trues. </p><p> </p><p> </p><p>Also, Monoid lifted by Applicative is also Monoid. This might be useful:</p><p> </p><p>newtype AMonoid f a = AMonoid {getAMonoid :: f a}</p><p> </p><p>instance (Applicative f, Semigroup a) => Semigroup (AMonoid f a) where</p><p>    (<>) = liftA2 (<>)</p><p> </p><p>instance (Applicative f, Monoid a) => Monoid (AMonoid f a) where</p><p>    mempty = pure mempty</p><p> </p></div></body></html><table style='display:none'><tr><td><img src="https://mail.naver.com/readReceipt/notify/?img=JlRCbHFTpz%2FYaqgZKrRZFAMrFzU%2FFAt9azU%2FKoCSFoCSa6U9pxvZp430a6UqtzFXp6UmaLl5WLl51zlqDBFdp6d5MreRhoRn16iZMBiGpBFg1zJq1rknWVlTb4b%3D.gif" border="0"/></td></tr></table>