monoid-extras-0.5: Various extra monoid-related definitions and utilities

Data.Monoid.SemiDirectProduct

Synopsis

# Documentation

data Semi s m #

The semi-direct product of monoids s and m, which is a monoid when m acts on s. Structurally, the semi-direct product is just a pair (s,m). However, the monoid instance is different. In particular, we have

(s1,m1) <> (s2,m2) = (s1 <> (m1 act s2), m1 <> m2)

We think of the m values as a "tag" decorating the s values, which also affect the way the s values combine.

We call the monoid m the quotient monoid and the monoid s the sub-monoid of the semi-direct product. The semi-direct product Semi s m is an extension of the monoid s with m being the quotient.

Instances
 (Semigroup m, Semigroup s, Action m s) => Semigroup (Semi s m) # Instance detailsDefined in Data.Monoid.SemiDirectProduct Methods(<>) :: Semi s m -> Semi s m -> Semi s m #sconcat :: NonEmpty (Semi s m) -> Semi s m #stimes :: Integral b => b -> Semi s m -> Semi s m # (Monoid m, Monoid s, Action m s) => Monoid (Semi s m) # Instance detailsDefined in Data.Monoid.SemiDirectProduct Methodsmempty :: Semi s m #mappend :: Semi s m -> Semi s m -> Semi s m #mconcat :: [Semi s m] -> Semi s m #

unSemi :: Semi s m -> (s, m) #

tag :: s -> m -> Semi s m #

Tag an s value with an m value to create an element of the semi-direct product.

inject :: Monoid m => s -> Semi s m #

The injection map, i.e. give an s value a trivial tag.

untag :: Semi s m -> s #

Forget the monoidal tag. Of course, untag . inject = id, and untag (tag s m) = s.

embed :: Monoid s => m -> Semi s m #

Embed a "tag" value as a value of type Semi s m. Note that

inject s <> embed m = tag s m

and

embed m <> inject s = tag (act m s) m@

The semi-direct product gives a split extension of s by m. This allows us to embed m into the semi-direct product. This is the embedding map. The quotient and embed maps should satisfy the equation quotient . embed = id.

quotient :: Semi s m -> m #

The quotient map, i.e. retrieve the monoidal tag value.