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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…