data-category-0.4.1: Category theory

Portabilitynon-portable
Stabilityexperimental
Maintainersjoerd@w3future.com

Data.Category.Functor

Contents

Description

 

Synopsis

Cat

data Cat whereSource

Functors are arrows in the category Cat.

Constructors

CatA :: (Functor ftag, Category (Dom ftag), Category (Cod ftag)) => ftag -> Cat (CatW (Dom ftag)) (CatW (Cod ftag)) 

Instances

Category Cat

Cat is the category with categories as objects and funtors as arrows.

HasTerminalObject Cat

Unit is the terminal category.

HasInitialObject Cat

The empty category is the initial object in Cat.

HasBinaryProducts Cat

The product of categories '(:**:)' is the binary product in Cat.

HasBinaryCoproducts Cat

The coproduct of categories '(:++:)' is the binary coproduct in Cat.

CartesianClosed Cat

Exponentials in Cat are the functor categories.

data CatW Source

We need a wrapper here because objects need to be of kind *, and categories are of kind * -> * -> *.

Functors

type family Dom ftag :: * -> * -> *Source

The domain, or source category, of the functor.

type family Cod ftag :: * -> * -> *Source

The codomain, or target category, of the functor.

class (Category (Dom ftag), Category (Cod ftag)) => Functor ftag whereSource

Functors map objects and arrows.

Methods

(%) :: ftag -> Dom ftag a b -> Cod ftag (ftag :% a) (ftag :% b)Source

% maps arrows.

Instances

Functor ForgetMonoid

The ForgetMonoid functor forgets the monoid structure.

Functor FreeMonoid

The FreeMonoid functor is the list functor.

Category ~> => Functor (Id ~>)

The identity functor on (~>)

(Category (Dom f), Category (Cod f)) => Functor (Opposite f)

The dual of a functor

Category ~> => Functor (OpOp ~>)

The Op (Op x) = x functor.

Category ~> => Functor (OpOpInv ~>)

The x = Op (Op x) functor.

Functor (EndoHask f)

EndoHask is a wrapper to turn instances of the Functor class into categorical functors.

Category ~> => Functor (DiagProd ~>)

DiagProd is the diagonal functor for products.

Category ~> => Functor (Hom ~>)

The Hom functor, Hom(--,--), a bifunctor contravariant in its first argument and covariant in its second argument.

Category ~> => Functor (FunctorCompose ~>)

Composition of endofunctors is a functor.

Category ~> => Functor (CodiagCoprod ~>)

CodiagCoprod is the codiagonal functor for coproducts.

Category (Discrete n) => Functor (Succ n)

Succ maps each object in Discrete n to its successor in Discrete (S n).

HasBinaryProducts ~> => Functor (ProductFunctor ~>)

Binary product as a bifunctor.

HasBinaryCoproducts ~> => Functor (CoproductFunctor ~>)

Binary coproduct as a bifunctor.

CartesianClosed ~> => Functor (ExpFunctor ~>)

The exponential as a bifunctor.

(Dom m ~ ~>, Cod m ~ ~>, Functor m) => Functor (KleisliAdjF m) 
(Dom m ~ ~>, Cod m ~ ~>, Functor m) => Functor (KleisliAdjG m) 
(Dom m ~ ~>, Cod m ~ ~>, Functor m) => Functor (FreeAlg m)

FreeAlg M takes x to the free algebra (M x, mu_x) of the monad M.

(Dom m ~ ~>, Cod m ~ ~>, Functor m) => Functor (ForgetAlg m)

ForgetAlg m is the forgetful functor for Alg m.

(Category (Cod g), Category (Dom h)) => Functor (:.: g h)

The composition of two functors.

(Category c1, Category c2) => Functor (Proj1 c1 c2)

Proj1 is a bifunctor that projects out the first component of a product.

(Category c1, Category c2) => Functor (Proj2 c1 c2)

Proj2 is a bifunctor that projects out the second component of a product.

(Functor f1, Functor f2) => Functor (:***: f1 f2)

f1 :***: f2 is the product of the functors f1 and f2.

(Functor f, Category d) => Functor (Precompose f d)

Precompose f d is the functor such that Precompose f d :% g = g :.: f, for functors g that compose with f and with codomain d.

(Functor f, Category c) => Functor (Postcompose f c)

Postcompose f c is the functor such that Postcompose f c :% g = f :.: g, for functors g that compose with f and with domain c.

(Functor f, Functor h) => Functor (Wrap f h)

Wrap f h is the functor such that Wrap f h :% g = f :.: g :.: h, for functors g that compose with f and h.

(Category c1, Category c2) => Functor (Inj1 c1 c2)

Inj1 is a functor which injects into the left category.

(Category c1, Category c2) => Functor (Inj2 c1 c2)

Inj2 is a functor which injects into the right category.

(Functor f1, Functor f2) => Functor (:+++: f1 f2)

f1 :+++: f2 is the coproduct of the functors f1 and f2.

(Category j, Category ~>) => Functor (Diag j ~>)

The diagonal functor from (index-) category J to (~>).

HasLimits j ~> => Functor (LimitFunctor j ~>)

If every diagram of type j has a limit in (~>) there exists a limit functor. It can be seen as a generalisation of (***).

HasColimits j ~> => Functor (ColimitFunctor j ~>)

If every diagram of type j has a colimit in (~>) there exists a colimit functor. It can be seen as a generalisation of (+++).

(Category (Dom p), Category (Cod p)) => Functor (:*: p q)

The product of two functors, passing the same object to both functors and taking the product of the results.

(Category (Dom p), Category (Cod p)) => Functor (:+: p q)

The coproduct of two functors, passing the same object to both functors and taking the coproduct of the results.

(Category y, Category z) => Functor (Apply y z)

Apply is a bifunctor, Apply :% (f, a) applies f to a, i.e. f :% a.

(Category y, Category z) => Functor (ToTuple1 y z)

ToTuple1 converts an object a to the functor Tuple1 a.

(Category y, Category z) => Functor (ToTuple2 y z)

ToTuple2 converts an object a to the functor Tuple2 a.

(Dom f ~ Op ~>, Cod f ~ (->), Category ~>, Functor f) => Functor (Yoneda ~> f)

Yoneda converts a functor f into a natural transformation from the hom functor to f.

(Category (Dom f), Category (Cod f)) => Functor (NatAsFunctor f g)

A natural transformation Nat c d is isomorphic to a functor from c :**: 2 to d.

(Category c1, Category c2) => Functor (Const c1 c2 x)

The constant functor.

(Category c1, Category c2) => Functor (Tuple1 c1 c2 a1)

Tuple1 tuples with a fixed object on the left.

(Category c1, Category c2) => Functor (Tuple2 c1 c2 a2)

Tuple2 tuples with a fixed object on the right.

(Category c1, Category c2) => Functor (Cotuple1 c1 c2 a1)

Cotuple1 projects out to the left category, replacing a value from the right category with a fixed object.

(Category c1, Category c2) => Functor (Cotuple2 c1 c2 a2)

Cotuple2 projects out to the right category, replacing a value from the left category with a fixed object.

Functor (DiscreteDiagram ~> n xs) => Functor (DiscreteDiagram ~> (S n) (x, xs))

A diagram with one more object.

Category ~> => Functor (DiscreteDiagram ~> Z ())

The empty diagram.

type family ftag :% a :: *Source

:% maps objects.

Functor instances

data Id (~>) Source

Constructors

Id 

Instances

Category ~> => Functor (Id ~>)

The identity functor on (~>)

Functor f => HasTerminalObject (Dialg (Id (->)) (EndoHask f))

FixF also provides the terminal F-coalgebra for endofunctors in Hask.

Functor f => HasInitialObject (Dialg (EndoHask f) (Id (->)))

FixF provides the initial F-algebra for endofunctors in Hask.

data g :.: h whereSource

Constructors

:.: :: (Functor g, Functor h, Cod h ~ Dom g) => g -> h -> g :.: h 

Instances

(Category (Cod g), Category (Dom h)) => Functor (:.: g h)

The composition of two functors.

data Const c1 c2 x whereSource

Constructors

Const :: Category c2 => Obj c2 x -> Const c1 c2 x 

Instances

(Category c1, Category c2) => Functor (Const c1 c2 x)

The constant functor.

type ConstF f = Const (Dom f) (Cod f)Source

The constant functor with the same domain and codomain as f.

data Opposite f whereSource

Constructors

Opposite :: Functor f => f -> Opposite f 

Instances

(Category (Dom f), Category (Cod f)) => Functor (Opposite f)

The dual of a functor

data OpOp (~>) Source

Constructors

OpOp 

Instances

Category ~> => Functor (OpOp ~>)

The Op (Op x) = x functor.

data OpOpInv (~>) Source

Constructors

OpOpInv 

Instances

Category ~> => Functor (OpOpInv ~>)

The x = Op (Op x) functor.

data EndoHask whereSource

Constructors

EndoHask :: Functor f => EndoHask f 

Instances

Functor (EndoHask f)

EndoHask is a wrapper to turn instances of the Functor class into categorical functors.

Functor f => HasTerminalObject (Dialg (Id (->)) (EndoHask f))

FixF also provides the terminal F-coalgebra for endofunctors in Hask.

Functor f => HasInitialObject (Dialg (EndoHask f) (Id (->)))

FixF provides the initial F-algebra for endofunctors in Hask.

Related to the product category

data Proj1 c1 c2 Source

Constructors

Proj1 

Instances

(Category c1, Category c2) => Functor (Proj1 c1 c2)

Proj1 is a bifunctor that projects out the first component of a product.

data Proj2 c1 c2 Source

Constructors

Proj2 

Instances

(Category c1, Category c2) => Functor (Proj2 c1 c2)

Proj2 is a bifunctor that projects out the second component of a product.

data f1 :***: f2 Source

Constructors

f1 :***: f2 

Instances

(Functor f1, Functor f2) => Functor (:***: f1 f2)

f1 :***: f2 is the product of the functors f1 and f2.

data DiagProd (~>) Source

Constructors

DiagProd 

Instances

Category ~> => Functor (DiagProd ~>)

DiagProd is the diagonal functor for products.

HasInitialObject (Dialg (Tuple1 (->) (->) ()) (DiagProd (->)))

The category for defining the natural numbers and primitive recursion can be described as Dialg(F,G), with F(A)=<1,A> and G(A)=<A,A>.

data Tuple1 c1 c2 a Source

Constructors

Tuple1 (Obj c1 a) 

Instances

HasInitialObject (Dialg (Tuple1 (->) (->) ()) (DiagProd (->)))

The category for defining the natural numbers and primitive recursion can be described as Dialg(F,G), with F(A)=<1,A> and G(A)=<A,A>.

(Category c1, Category c2) => Functor (Tuple1 c1 c2 a1)

Tuple1 tuples with a fixed object on the left.

data Tuple2 c1 c2 a Source

Constructors

Tuple2 (Obj c2 a) 

Instances

(Category c1, Category c2) => Functor (Tuple2 c1 c2 a2)

Tuple2 tuples with a fixed object on the right.

Hom functors

data Hom (~>) Source

Constructors

Hom 

Instances

Category ~> => Functor (Hom ~>)

The Hom functor, Hom(--,--), a bifunctor contravariant in its first argument and covariant in its second argument.

type :*-: x (~>) = Hom ~> :.: Tuple1 (Op ~>) ~> xSource

homX_ :: Category ~> => Obj ~> x -> x :*-: ~>Source

The covariant functor Hom(X,--)

type :-*: (~>) x = Hom ~> :.: Tuple2 (Op ~>) ~> xSource

hom_X :: Category ~> => Obj ~> x -> ~> :-*: xSource

The contravariant functor Hom(--,X)