I think I might have stumbled across a general, albeit somewhat degenerate, monoid action. Pseudo-Haskell:
instance (Monoid m, Monoid n) => Act m n where
act mempty x = x -- let's pretend that we can use `mempty` as a pattern
act _ _ = mempty
m
's action on n
is to set n
to mempty
unless m
itself is empty.
Is this a law-abiding monoid action? Has it been invented before by someone other than me? If so, what is its name?
It does not look as a monoid action, at least in the general case. If it were, we should have the following properties:
-- law 1
act mempty x = x
-- law 2
act (m1 <> m2) x = act m1 (act m2 x)
and, because of the way act
was defined in the pseudo-instance:
-- property 1
act x y = mempty
when x /= mempty
Take m
and n
to be Sum Int
, which is a monoid.
We have
act (Sum 0) (Sum 1)
= { definition of mempty }
act mempty (Sum 1)
= { law 1 }
Sum 1
we also have
act (Sum 0) (Sum 1)
= { definition of <> on Sum }
act (Sum (-2) <> Sum 2) (Sum 1)
= { law 2 }
act (Sum (-2)) (act (Sum 2) (Sum 1))
= { property 1, given Sum (-2) /= mempty }
mempty
= { definition of mempty }
Sum 0
leading to two incompatible results.
On the other side, when m
is a monoid where no (nontrivial) element has an inverse, e.g. [a]
, then your act
looks like a proper action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With