Functor
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and maps between these algebraic objects are associated to continuous maps between spaces. Nowadays, functors are used throughout modern mathematics to relate various categories. Thus, functors are important in all areas within mathematics to which category theory is applied. The words "category" and "functor" were borrowed by mathematicians from the philosophers Aristotle and Rudolf Carnap, respectively. The latter used "functor" in a linguistic context; see function word . Definition. Let "C" and "D" be categories. A functor "F" from "C" to "D" is a mapping that That is, functors must preserve identity morphisms and composition of morphisms. Covariance and contravariance. There are many constructions in mathematics that would be functors but for the fact that they "turn morphisms around" and "reverse composition". We then define a contravariant functor "F" from "C" to "D" as a mapping that Note that contravariant functors reverse the direction of composition. Ordinary functors are also called covariant functors in order to distinguish them from contravariant ones. Note that one can also define a  contravariant functor as a "covariant" functor on the opposite category formula_19. Some authors prefer to write all expressions covariantly. That is, instead of saying formula_20 is a contravariant functor, they simply write formula_21 (or sometimes formula_22) and call it a functor. Contravariant functors are also occasionally called "cofunctors". There is a convention which refers to "vectors"—i.e., vector fields, elements of the space of sections formula_23 of a tangent bundle formula_24—as "contravariant" and to "covectors"—i.e., 1-forms, elements of the space of sections formula_25 of a cotangent bundle formula_26—as "covariant". This terminology originates in physics, and its rationale has  to do with the position of the indices ("upstairs" and "downstairs") in expressions such as formula_27 for formula_28 or formula_29 for formula_30 In this formalism it is observed that the coordinate transformation symbol formula_31 (representing the matrix formula_32) acts on the basis vectors "in the same way" as on the "covector coordinates": formula_33—whereas it acts "in the opposite way" on the "vector coordinates" (but "in the same way" as on the basis covectors: formula_34). This terminology is contrary to the one used in category theory because it is the covectors that have "pullbacks" in general and are thus "contravariant , whereas vectors in general are covariant" since they can be "pushed forward". See also Covariance and contravariance of vectors. Opposite functor. Every functor formula_20 induces the opposite functor formula_36, where formula_19 and formula_38 are the opposite categories to formula_39 and formula_40. By definition, formula_41 maps objects and morphisms identically to formula_42. Since formula_19 does not coincide with formula_39 as a category, and similarly for formula_40, formula_41 is distinguished from formula_42. For example, when composing formula_48 with formula_49, one should use either formula_50 or formula_51. Note that, following the property of opposite category, formula_52. Bifunctors and multifunctors. A bifunctor (also known  as a binary functor) is a functor whose domain is a product category. For example, the Hom functor is of the type . It can be seen as a functor in "two" arguments. The Hom functor is a natural example; it is contravariant in one argument, covariant in the other. A multifunctor is a generalization of the functor concept to "n" variables. So, for example, a bifunctor is a multifunctor with . Properties. Two important consequences of the functor axioms are: One can compose functors, i.e. if "F" is a functor from "A" to "B" and "G" is a functor from "B  to C" then one can form the composite functor from "A" to "C". Composition of functors is associative where defined. Identity of composition of functors is the identity functor. This shows that functors can be considered as morphisms in categories of categories, for example in the category of small categories. A small category with a single object is the same thing as a monoid: the morphisms of a one-object category can be thought of as elements of the monoid, and composition in the category is thought of as the monoid operation. Functors between one-object categories correspond to monoid  homomorphisms. So in a sense, functors between arbitrary categories are a kind of generalization of monoid homomorphisms to categories with more than one object. Examples. Doing this constructions pointwise gives the tangent space, a covariant functor from the category of pointed differentiable manifolds to the category of real vector spaces. Likewise, cotangent space is a contravariant functor, essentially the composition of the tangent space with the dual space above. Relation to other categorical concepts. Let "C" and "D" be categories. The collection of all functors from "C" to "D" forms the objects of a category: the functor category. Morphisms in  this category are natural transformations between functors. Functors are often defined by universal properties; examples are the tensor product, the direct sum and direct product of groups or vector spaces, construction of free groups and modules, direct and inverse limits. The concepts of limit and colimit generalize several of the above. Universal constructions often give rise to pairs of adjoint functors. Computer implementations. Functors sometimes appear in functional programming. For instance, the programming language Haskell has a class codice_1 where codice_2 is a polytypic function used to map functions ("morphisms" on "Hask", the category of Haskell types) between existing types  to functions between some new types.