I would like to suggest that we define the following instances:
instance semigroupParity :: Semigroup Parity where
append Even Even = Even
append Even Odd = Odd
append Odd Even = Odd
append Odd Odd = Even
instance monoidParity :: Monoid Parity where
mempty = Even
-- I guess this would need to go in a separate library, since groups aren't defined in core afaik
instance groupParity :: Group Parity where
ginverse = id
(as a group, Parity would be isomorphic to the group ℤ/2ℤ).
A nice consequence of doing this would be that parity :: Int -> Parity becomes a group homomorphism, where the group over Int we are considering is the additive one. That is,
parity x <> parity y = parity (x + y)
holds for all x, y :: Int. Additionally, the function parity :: Sym -> Parity in my symmetric-groups library, where Sym is the type of permutations on the set {1,2,...n} for some (finite) n, would also become a group homomorphism.
I would like to suggest that we define the following instances:
(as a group,
Paritywould be isomorphic to the group ℤ/2ℤ).A nice consequence of doing this would be that
parity :: Int -> Paritybecomes a group homomorphism, where the group overIntwe are considering is the additive one. That is,holds for all
x, y :: Int. Additionally, the functionparity :: Sym -> Parityin my symmetric-groups library, whereSymis the type of permutations on the set{1,2,...n}for some (finite) n, would also become a group homomorphism.