Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class (Associative cat t1, Associative cat t0) => Semigroupal cat t1 t0 f where
- combine :: (f x `t0` f x') `cat` f (x `t1` x')
- class Unital cat i1 i0 f where
- introduce :: cat i0 (f i1)
- 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
Semigroupal
class (Associative cat t1, Associative cat t0) => Semigroupal cat t1 t0 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 Semigroupal
if it supports a natural transformation
\(\phi_{A,B} : F\ A \bullet F\ B \to F\ (A \otimes B)\), 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
assoc
≡fmap
(bwd
assoc
).
combine
.
glmap
combine
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
>>>
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
Alternative f => Semigroupal (->) Either (,) f Source # | |
Defined in Data.Functor.Monoidal | |
Semialign f => Semigroupal (->) These (,) f Source # | |
Defined in Data.Functor.Monoidal | |
Applicative f => Semigroupal (->) (,) (,) f Source # | |
Defined in Data.Functor.Monoidal |
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
.
introduce :: cat i0 (f i1) Source #
introduce
maps from the identity in \(\mathcal{C}\) to the
identity in \(\mathcal{D}\).
Examples
>>>
introduce @(->) @() @() @Maybe ()
Just ()
>>>
:t introduce @(->) @Void @() @Maybe
introduce @(->) @Void @() @Maybe :: () -> Maybe Void
>>>
introduce @(->) @Void @() @Maybe ()
Nothing
Instances
Alternative f => Unital (->) Void () f Source # | |
Defined in Data.Functor.Monoidal | |
Applicative f => Unital (->) () () f Source # | |
Defined in Data.Functor.Monoidal |
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
introduce
≡bwd
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
introduce
≡fmap
(bwd
unitl
).
fwd
unitl
Instances
Alternative f => Monoidal (->) Either Void (,) () f Source # | |
Defined in Data.Functor.Monoidal | |
(Alternative f, Semialign f) => Monoidal (->) These Void (,) () f Source # | |
Defined in Data.Functor.Monoidal | |
Applicative f => Monoidal (->) (,) () (,) () f Source # | |
Defined in Data.Functor.Monoidal |