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

Copyright(c) 2011-2015 diagrams-core team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellSafe
LanguageHaskell2010

Data.Monoid.Coproduct

Description

The coproduct of two monoids.

Synopsis

Documentation

data m :+: n Source #

m :+: n is the coproduct of monoids m and n. Values of type m :+: n consist of alternating lists of m and n values. The empty list is the identity, and composition is list concatenation, with appropriate combining of adjacent elements when possible.

Instances

(Show m, Show n) => Show ((:+:) m n) Source # 

Methods

showsPrec :: Int -> (m :+: n) -> ShowS #

show :: (m :+: n) -> String #

showList :: [m :+: n] -> ShowS #

Semigroup ((:+:) m n) Source # 

Methods

(<>) :: (m :+: n) -> (m :+: n) -> m :+: n #

sconcat :: NonEmpty (m :+: n) -> m :+: n #

stimes :: Integral b => b -> (m :+: n) -> m :+: n #

Monoid ((:+:) m n) Source #

The coproduct of two monoids is itself a monoid.

Methods

mempty :: m :+: n #

mappend :: (m :+: n) -> (m :+: n) -> m :+: n #

mconcat :: [m :+: n] -> m :+: n #

(Action m r, Action n r) => Action ((:+:) m n) r Source #

Coproducts act on other things by having each of the components act individually.

Methods

act :: (m :+: n) -> r -> r Source #

inL :: m -> m :+: n Source #

Injection from the left monoid into a coproduct.

inR :: n -> m :+: n Source #

Injection from the right monoid into a coproduct.

mappendL :: m -> (m :+: n) -> m :+: n Source #

Prepend a value from the left monoid.

mappendR :: n -> (m :+: n) -> m :+: n Source #

Prepend a value from the right monoid.

killL :: Monoid n => (m :+: n) -> n Source #

killL takes a value in a coproduct monoid and sends all the values from the left monoid to the identity.

killR :: Monoid m => (m :+: n) -> m Source #

killR takes a value in a coproduct monoid and sends all the values from the right monoid to the identity.

untangle :: (Action m n, Monoid m, Monoid n) => (m :+: n) -> (m, n) Source #

Take a value from a coproduct monoid where the left monoid has an action on the right, and "untangle" it into a pair of values. In particular,

m1 <> n1 <> m2 <> n2 <> m3 <> n3 <> ...

is sent to

(m1 <> m2 <> m3 <> ..., (act m1 n1) <> (act (m1 <> m2) n2) <> (act (m1 <> m2 <> m3) n3) <> ...)

That is, before combining n values, every n value is acted on by all the m values to its left.