module XOR where -- Both + and * are associative operators with identity elements for Integer, so -- which one should we use to make Integer an instance of Semigroup and -- Monoid? -- -- Both && and || are associative operators with identity elements for Bool, so -- which one should we use to make Bool an instance of Semigroup and Monoid? -- -- The Haskell community decided to do none of the above, but instead use -- wrapper types. You will do something similar in this lab. -- -- Logical-xor is also an associative operator for Bool. We won't make Bool an -- instance of Semigroup and Monoid directly. We define this type wrapping -- Bool: data BoolX = MkBoolX Bool deriving (Eq, Show) -- Make BoolX an instance of Semigroup and Monoid. The <> operator should do -- logical xor. mempty should be the corresponding identity element. instance Semigroup BoolX where -- Reminder: (<>) :: BoolX -> BoolX -> BoolX instance Monoid BoolX where -- Reminder: mempty :: BoolX -- In Data.Semigroup, you can find similar wrapper types: -- All wraps Bool and makes <> do logical-and -- Any wraps Bool and makes <> do logical-or -- Sum wraps a Num instance and makes <> do addition -- Product wraps a Num instance and makes <> do multiplication