Processing math: 20%
monoidal-functors-0.2.0.0: Monoidal Functors Library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Functor.Monoidal

Synopsis

Semigroupal

class (Associative cat t1, Associative cat t0) => Semigroupal cat t1 t0 f where Source #

Given monoidal categories (C,,IC) and (D,,ID). A functor F:CD is Semigroupal if it supports a natural transformation ϕA,B:F AF BF (AB), which we call combine.

Laws

Associativity:

\require{AMScd} \begin{CD} (F A \bullet F B) \bullet F C @>>{\alpha_{\mathcal{D}}}> F A \bullet (F B \bullet F C) \\ @VV{\phi_{A,B} \bullet 1}V @VV{1 \bullet \phi_{B,C}}V \\ F (A \otimes B) \bullet F C @. F A \bullet (F (B \otimes C)) \\ @VV{\phi_{A \otimes B,C}}V @VV{\phi_{A,B \otimes C}}V \\ F ((A \otimes B) \otimes C) @>>{F \alpha_{\mathcal{C}}}> F (A \otimes (B \otimes C)) \\ \end{CD}

combine . grmap combine . bwd assocfmap (bwd assoc) . combine . glmap combine

Methods

combine :: (f x `t0` f x') `cat` f (x `t1` x') Source #

combine is a natural transformation from functors \mathcal{C} × \mathcal{C} to \mathcal{D}.

Examples

Expand
>>> combine @(->) @(,) @(,) @Maybe (Just True, Just "hello")
Just (True,"hello")
>>> combine @(->) @(,) @(,) @Maybe (Just True, Nothing)
Nothing
>>> combine @(->) @Either @(,) @Maybe (Just True, Nothing)
Just (Left True)
>>> combine @(->) @Either @(,) @Maybe (Nothing, Just "hello")
Just (Right "hello")

Instances

Instances details
Alternative f => Semigroupal (->) Either (,) f Source # 
Instance details

Defined in Data.Functor.Monoidal

Methods

combine :: (f x, f x') -> f (Either x x') Source #

Semialign f => Semigroupal (->) These (,) f Source # 
Instance details

Defined in Data.Functor.Monoidal

Methods

combine :: (f x, f x') -> f (These x x') Source #

Applicative f => Semigroupal (->) (,) (,) f Source # 
Instance details

Defined in Data.Functor.Monoidal

Methods

combine :: (f x, f x') -> f (x, x') Source #

Unital

class Unital cat i1 i0 f where Source #

Given monoidal categories (\mathcal{C}, \otimes, I_{\mathcal{C}}) and (\mathcal{D}, \bullet, I_{\mathcal{D}}). A functor F : \mathcal{C} \to \mathcal{D} is Unital if it supports a morphism \phi : I_{\mathcal{D}} \to F\ I_{\mathcal{C}}, which we call introduce.

Methods

introduce :: cat i0 (f i1) Source #

introduce maps from the identity in \mathcal{C} to the identity in \mathcal{D}.

Examples

Expand
>>> introduce @(->) @() @() @Maybe ()
Just ()
>>> :t introduce @(->) @Void @() @Maybe
introduce @(->) @Void @() @Maybe :: () -> Maybe Void
>>> introduce @(->) @Void @() @Maybe ()
Nothing

Instances

Instances details
Alternative f => Unital (->) Void () f Source # 
Instance details

Defined in Data.Functor.Monoidal

Methods

introduce :: () -> f Void Source #

Applicative f => Unital (->) () () f Source # 
Instance details

Defined in Data.Functor.Monoidal

Methods

introduce :: () -> f () Source #

Monoidal

class (Tensor cat t1 i1, Tensor cat t0 i0, Semigroupal cat t1 t0 f, Unital cat i1 i0 f) => Monoidal cat t1 i1 t0 i0 f Source #

Given monoidal categories (\mathcal{C}, \otimes, I_{\mathcal{C}}) and (\mathcal{D}, \bullet, I_{\mathcal{D}}). A functor F : \mathcal{C} \to \mathcal{D} is Monoidal if it maps between \mathcal{C} and \mathcal{D} while preserving their monoidal structure. Eg., a homomorphism of monoidal categories.

See NCatlab for more details.

Laws

Right Unitality:

\require{AMScd} \begin{CD} F A \bullet I_{\mathcal{D}} @>{1 \bullet \phi}>> F A \bullet F I_{\mathcal{C}};\\ @VV{\rho_{\mathcal{D}}}V @VV{\phi A,I_{\mathcal{C}}}V \\ F A @<<{F \rho_{\mathcal{C}}}< F (A \otimes I_{\mathcal{C}}); \end{CD}

  combine . grmap introducebwd unitr . fwd unitr

Left Unitality:

\begin{CD} I_{\mathcal{D}} \bullet F B @>{\phi \bullet 1}>> F I_{\mathcal{C}} \bullet F B;\\ @VV{\lambda_{\mathcal{D}}}V @VV{\phi I_{\mathcal{C}},B}V \\ F A @<<{F \lambda_{\mathcal{C}}}< F (A \otimes I_{\mathcal{C}} \otimes B); \end{CD}

  combine . glmap introducefmap (bwd unitl) . fwd unitl

Instances

Instances details
Alternative f => Monoidal (->) Either Void (,) () f Source # 
Instance details

Defined in Data.Functor.Monoidal

(Alternative f, Semialign f) => Monoidal (->) These Void (,) () f Source # 
Instance details

Defined in Data.Functor.Monoidal

Applicative f => Monoidal (->) (,) () (,) () f Source # 
Instance details

Defined in Data.Functor.Monoidal