Skip to content

Monoid Parity instance? #30

@hdgarrood

Description

@hdgarrood

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions