Monoid and semigroup actions.
Type class for monoid (and semigroup) actions, where monoidal
values of type
m "act" on values of another type
Instances are required to satisfy the laws
act mempty = id
act (m1 `
mappend` m2) = act m1 . act m2
Semigroup instances are required to satisfy the second law but with
'()' instead of
mappend. Additionally, if the type
any algebraic structure,
act m should be a homomorphism. For
s is also a monoid we should have
act m mempty =
act m (s1 `.
mappend` s2) = (act m s1) `
(act m s2)
act = const id, so for a type
M which should have
no action on anything, it suffices to write
instance Action M s
with no method implementations.
|Action () l|
|(Action m a, Action m b) => Action m (a, b)|
Actions operate elementwise on pairs.
|(Action m a, Action m b, Action m c) => Action m (a, b, c)|
Actions operate elementwise on triples.
|Action m s => Action (Option m) s|
|Action (SM a) ()|
|Action m n => Action (Split m) n|
By default, the action of a split monoid is the same as for the underlying monoid, as if the split were removed.
|(Action a a', Action (SM a) l) => Action (SM a) (Option a', l)|
|(Action (SM a) l2, Action l1 l2) => Action (a, l1) l2|
|(Action m r, Action n r) => Action (:+: m n) r|
Coproducts act on other things by having each of the components act individually.