joelburget/plur

Semigroup instance breaks associativity

Closed this issue · 0 comments

The definition

instance Semigroup (Plur a) where
  r1      <> Zero    = r1
  Zero    <> r2      = r2
  One x   <> One y   = Two x y
  One x   <> Two y _ = Two x y
  Two x _ <> One y   = Two x y
  Two x _ <> Two y _ = Two x y

is unlawful.

(Two x a <> Two y b) <> Two z c => Two x z
Two x a <> (Two y b <> Two z c) => Two x y