For as far as I understand, a functor is a mapping between two categories, for example from objects in to objects in
where
and
are categories.
In Haskell there is Hask in which the objects are Haskell types and the morphisms are Haskell functions. However, the Functor
type class has a function fmap
which maps between these types (which are thus objects and not categories themselves):
fmap :: (a -> b) -> f a -> f b
f a
and f b
are both objects in Hask. Does this mean every instance of Functor
in Haskell is an endofunctor, and if not does Functor
really represent a functor?
What am I missing here? Are types also categories in Haskell?