data-category-0.4.1: Category theory

Portabilitynon-portable
Stabilityexperimental
Maintainersjoerd@w3future.com

Data.Category.Monoidal

Description

 

Synopsis

Documentation

class Functor f => TensorProduct f whereSource

A monoidal category is a category with some kind of tensor product. A tensor product is a bifunctor, with a unit object.

Associated Types

type Unit f :: *Source

Methods

unitObject :: f -> Obj (Cod f) (Unit f)Source

leftUnitor :: Cod f ~ ~> => f -> Obj ~> a -> (f :% (Unit f, a)) ~> aSource

leftUnitorInv :: Cod f ~ ~> => f -> Obj ~> a -> a ~> (f :% (Unit f, a))Source

rightUnitor :: Cod f ~ ~> => f -> Obj ~> a -> (f :% (a, Unit f)) ~> aSource

rightUnitorInv :: Cod f ~ ~> => f -> Obj ~> a -> a ~> (f :% (a, Unit f))Source

associator :: Cod f ~ ~> => f -> Obj ~> a -> Obj ~> b -> Obj ~> c -> (f :% (f :% (a, b), c)) ~> (f :% (a, f :% (b, c)))Source

associatorInv :: Cod f ~ ~> => f -> Obj ~> a -> Obj ~> b -> Obj ~> c -> (f :% (a, f :% (b, c))) ~> (f :% (f :% (a, b), c))Source

Instances

Category ~> => TensorProduct (FunctorCompose ~>)

Functor composition makes the category of endofunctors monoidal, with the identity functor as unit.

(HasTerminalObject ~>, HasBinaryProducts ~>) => TensorProduct (ProductFunctor ~>)

If a category has all products, then the product functor makes it a monoidal category, with the terminal object as unit.

(HasInitialObject ~>, HasBinaryCoproducts ~>) => TensorProduct (CoproductFunctor ~>)

If a category has all coproducts, then the coproduct functor makes it a monoidal category, with the initial object as unit.

data MonoidObject f a Source

MonoidObject f a defines a monoid a in a monoidal category with tensor product f.

Constructors

MonoidObject 

Fields

unit :: Cod f ~ ~> => Unit f ~> a
 
multiply :: Cod f ~ ~> => (f :% (a, a)) ~> a
 

data ComonoidObject f a Source

ComonoidObject f a defines a comonoid a in a comonoidal category with tensor product f.

Constructors

ComonoidObject 

Fields

counit :: Cod f ~ ~> => a ~> Unit f
 
comultiply :: Cod f ~ ~> => a ~> (f :% (a, a))
 

preludeMonoid :: Monoid m => MonoidObject (ProductFunctor (->)) mSource

Monoids as defined in the prelude are monoids in Hask with the product functor as tensor product.

data MonoidAsCategory f m a b whereSource

Constructors

MonoidValue :: (TensorProduct f, Dom f ~ ~> :**: ~>, Cod f ~ ~>) => f -> MonoidObject f m -> (Unit f ~> m) -> MonoidAsCategory f m m m 

Instances

Category (MonoidAsCategory f m)

A monoid as a category with one object.

type Monad f = MonoidObject (FunctorCompose (Dom f)) fSource

A monad is a monoid in the category of endofunctors.

mkMonad :: (Functor f, Dom f ~ ~>, Cod f ~ ~>, Category ~>) => f -> (forall a. Obj ~> a -> Component (Id ~>) f a) -> (forall a. Obj ~> a -> Component (f :.: f) f a) -> Monad fSource

type Comonad f = ComonoidObject (FunctorCompose (Dom f)) fSource

A comonad is a comonoid in the category of endofunctors.

mkComonad :: (Functor f, Dom f ~ ~>, Cod f ~ ~>, Category ~>) => f -> (forall a. Obj ~> a -> Component f (Id ~>) a) -> (forall a. Obj ~> a -> Component f (f :.: f) a) -> Comonad fSource

adjunctionMonad :: Adjunction c d f g -> Monad (g :.: f)Source

Every adjunction gives rise to an associated monad.

adjunctionComonad :: Adjunction c d f g -> Comonad (f :.: g)Source

Every adjunction gives rise to an associated comonad.