HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulemonoid-extras-0.7.0.2Haskell2010

Data.Monoid.SemiDirectProduct

  • 1 type
  • 6 values
newtypenewtype 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.

NOTE: this is only a valid semigroup/monoid if the action of m on s satisfies BOTH:

  1. act is a monoid/semigroup homomorphism from m to (s -> s), that is, act mempty = id and act (m1 <> m2) = act m1 . act m2

  2. act m is a monoid/semigroup homomorphism for any m, that is, act m mempty = mempty and act m (s1 <> s2) = act m s1 <> act m s2.

For a more fine-grained treatment of these ideas, see the lr-acts package.

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.

Instances2Semigroup, Monoid
valuetag :: s -> m -> Semi s m
#

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

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

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

valueuntag :: Semi s m -> s
#

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

valueembed :: 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.

valuequotient :: Semi s m -> m
#

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