Examples of using Functor in English and their translations into Chinese
{-}
-
Political
-
Ecclesiastic
-
Programming
F*F^* is a functor.
A functor maps a category to another category.
Where F is a functor.
A functor which is both faithful and full is called fully faithful.
Which defines a functor.
A functor from a category to itself is called an endofunctor.
Where the'f' is a functor.
A functor also maps morphisms, so it is a higher order function- fmap.
And satisfies the functor laws:.
The functor Reader() takes any type a and maps it into a function type()-gt;a.
So, the identity map is a functor.
In Haskell, the action of a functor G on a morphism f is implemented using fmap.
A functor F: C→ D yields an equivalence of categories if and only if it is simultaneously:.
An object in Hask is a type, so our functor must map types into types.
The functor category between categories C and D is written as Fun(C, D), or[C, D], or sometimes as DC.
You might remember the example of a contravariant functor we have looked at before:.
The way to look at it is that a functor in Hask constructs one type from another- it's a type constructor.
Now let's consider natural transformations from this functor to the Maybe functor:.
Pluck will work on any functor in addition to arrays, as it is equivalent to R. map(R. prop(k), f).
For instance, length can be thought of as a natural transformation from the list functor to the Const Int functor:.
How likely is it that it also defines a functor(loosely speaking- C++ is not as mathematized as Haskell)?
The list functor obviously preserves function composition and identity(I will leave it as an easy but instructive exercise for the reader).
The quickest way to define a contravariant functor is as a covariant functor from the opposite category Cop to D.
Functors in Haskell are from Hask to func, where func is the subcategory of Hask defined on just that functor's types.
Unfortunately they can also be quite cumbersome to use,particularly if the functor you would like to apply is unique to the particular function.
Finally, for each functor F there is an identity natural transformation 1F whose components are the identity morphisms:.
This is not a functor because the same type a is used both in the negative(contravariant) and positive(covariant) position.
We can, however, re-interpret the functor arrow as a special kind of natural transformation: the identity natural transformation acting on this functor.
Takes a function and a functor, applies the function to each of the functor's values, and returns a functor of the same shape.