Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | sjoerd@w3future.com |
- class Functor f => TensorProduct f where
- type Unit f :: *
- unitObject :: f -> Obj (Cod f) (Unit f)
- leftUnitor :: Cod f ~ ~> => f -> Obj ~> a -> (f :% (Unit f, a)) ~> a
- leftUnitorInv :: Cod f ~ ~> => f -> Obj ~> a -> a ~> (f :% (Unit f, a))
- rightUnitor :: Cod f ~ ~> => f -> Obj ~> a -> (f :% (a, Unit f)) ~> a
- rightUnitorInv :: Cod f ~ ~> => f -> Obj ~> a -> a ~> (f :% (a, Unit f))
- associator :: Cod f ~ ~> => f -> Obj ~> a -> Obj ~> b -> Obj ~> c -> (f :% (f :% (a, b), c)) ~> (f :% (a, f :% (b, c)))
- associatorInv :: Cod f ~ ~> => f -> Obj ~> a -> Obj ~> b -> Obj ~> c -> (f :% (a, f :% (b, c))) ~> (f :% (f :% (a, b), c))
- data MonoidObject f a = MonoidObject {}
- data ComonoidObject f a = ComonoidObject {}
- preludeMonoid :: Monoid m => MonoidObject (ProductFunctor (->)) m
- data MonoidAsCategory f m a b where
- MonoidValue :: (TensorProduct f, Dom f ~ ~> :**: ~>, Cod f ~ ~>) => f -> MonoidObject f m -> (Unit f ~> m) -> MonoidAsCategory f m m m
- type Monad f = MonoidObject (FunctorCompose (Dom f)) f
- 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 f
- preludeMonad :: (Functor f, Monad f) => Monad (EndoHask f)
- monadFunctor :: Monad f -> f
- type Comonad f = ComonoidObject (FunctorCompose (Dom f)) f
- 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 f
- adjunctionMonad :: Adjunction c d f g -> Monad (g :.: f)
- adjunctionComonad :: Adjunction c d f g -> Comonad (f :.: g)
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.
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
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
.
data ComonoidObject f a Source
ComonoidObject f a
defines a comonoid a
in a comonoidal category with tensor product f
.
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
MonoidValue :: (TensorProduct f, Dom f ~ ~> :**: ~>, Cod f ~ ~>) => f -> MonoidObject f m -> (Unit f ~> m) -> MonoidAsCategory f m m m |
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
monadFunctor :: Monad f -> 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.