changeset-0.1.0.2: Stateful monad transformer based on monoidal actions
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Monoid.RightAction.Coproduct

Synopsis

Documentation

newtype m :+: n Source #

The coproduct of two monoids is a monoid that can contain values of either constituent.

This is useful if you have two different actions on the same state type, and want to combine them.

Note: The multiplication of this monoid is formal, so the same semantic values may have differing representations. Therefore it's not advised to inspect the contents of a coproduct. You should usually want to use normaliseCoproduct.

Constructors

Coproduct 

Fields

Instances

Instances details
Monoid (m :+: n) Source # 
Instance details

Defined in Data.Monoid.RightAction.Coproduct

Methods

mempty :: m :+: n #

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

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

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

Defined in Data.Monoid.RightAction.Coproduct

Methods

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

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

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

(Eq m, Eq n, Semigroup m, Semigroup n) => Eq (m :+: n) Source #

Coproducts are compared after normalising

Instance details

Defined in Data.Monoid.RightAction.Coproduct

Methods

(==) :: (m :+: n) -> (m :+: n) -> Bool #

(/=) :: (m :+: n) -> (m :+: n) -> Bool #

(RightAction m s, RightAction n s) => RightAction (m :+: n) s Source # 
Instance details

Defined in Data.Monoid.RightAction.Coproduct

Methods

actRight :: s -> (m :+: n) -> s Source #

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

Construct a coproduct value from the left constituent monoid.

Semantically, this is a monoid homomorphism: inL m1 <> inL m2 acts the same as inL (m1 <> m2).

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

Construct a coproduct value from the right constituent monoid.

Semantically, this is a monoid homomorphism: inR m1 <> inR m2 acts the same as inR (m1 <> m2).

normaliseCoproduct :: (Semigroup m, Semigroup n) => (m :+: n) -> [Either m n] Source #

Brings a coproduct into a canonical form, which is an alternating list of Lefts and Rights.

(The list may start with a Left or a Right, or be empty.)