Difference between revisions of "Category theory/Functor"
m (add nLab Functor and Endofunctor entry, Wiki Functor entry and Typeclassopedia Functor articles) |
|||
(One intermediate revision by one other user not shown) | |||
Line 25: | Line 25: | ||
=== The category Cat === |
=== The category Cat === |
||
− | The existence of identity and composition functors implies that, for any well-defined collection of categories <math>E</math>, there exists a category <math>\mathrm{Cat}_E</math> whose arrows are all functors between categories in <math>E</math>. Since no category can include itself as an object, there can be no category of all categories, but it is |
+ | The existence of identity and composition functors implies that, for any well-defined collection of categories <math>E</math>, there exists a category <math>\mathrm{Cat}_E</math> whose arrows are all functors between categories in <math>E</math>. Since no category can include itself as an object, there can be no category of all categories, but it is common and useful to designate a category '''small''' when the collection of objects is a set, and define Cat to be the category whose objects are all small categories and whose arrows are all functors on small categories. |
=== Functors in Haskell === |
=== Functors in Haskell === |
||
Line 35: | Line 35: | ||
fmap :: (a -> b) -> (f a -> f b) |
fmap :: (a -> b) -> (f a -> f b) |
||
</haskell> |
</haskell> |
||
+ | |||
+ | == External links == |
||
+ | |||
+ | * Wikipedia's [https://en.wikipedia.org/wiki/Functor Functor] article |
||
+ | * nlab's [https://ncatlab.org/nlab/show/functor functor] and [https://ncatlab.org/nlab/show/endofunctor endofunctor] articles |
||
+ | * Typeclassopedia [https://wiki.haskell.org/Typeclassopedia#Functor Functor] article |
||
+ | |||
+ | [[Category:Theoretical foundations]] |
Latest revision as of 01:17, 16 April 2019
Definition of a Functor
Given that and are categories, a functor is a pair of mappings (the subscripts are generally omitted in practice).
Axioms
- If in , then in
- If in and in , then
- For all objects in ,
Examples of functors
- , the functor giving the free monoid over a set
- , the functor giving the free group over a set
- Every monotone function is a functor, when the underlying partial orders are viewed as categories
- Every monoid homomorphism is a functor, when the underlying monoids are viewed as categories
Functor operations
- For all categories , there is an identity functor (again, the subscript is usually ommitted) given by the rule for all objects and arrows .
- If and , then , with composition defined component-wise.
These operations will be important in the definition of a monad.
The category Cat
The existence of identity and composition functors implies that, for any well-defined collection of categories , there exists a category whose arrows are all functors between categories in . Since no category can include itself as an object, there can be no category of all categories, but it is common and useful to designate a category small when the collection of objects is a set, and define Cat to be the category whose objects are all small categories and whose arrows are all functors on small categories.
Functors in Haskell
Properly speaking, a functor in the category Haskell is a pair of a set-theoretic function on Haskell types and a set-theoretic function on Haskell functions satisfying the axioms. However, Haskell being a functional language, Haskellers are only interested in functors where both the object and arrow mappings can be defined and named in Haskell; this effectively restricts them to functors where the object map is a Haskell data constructor and the arrow map is a polymorphic function, the same constraints imposed by the class Functor:
class Functor f where
fmap :: (a -> b) -> (f a -> f b)
External links
- Wikipedia's Functor article
- nlab's functor and endofunctor articles
- Typeclassopedia Functor article