[Haskell-cafe] Better names for
olf at aatal-apotheke.de
Wed Apr 22 13:17:45 UTC 2020
> I've heard several times that some Haskell type classes and methods
> For instance, a functor can be both covariant and contravariant,
> Haskell `Functor` typeclass i just covariant. Would `Cofunctor` be a
> better name for it? And what about the `fmap` method? Would it be
> to call it `comap`? How about `Bifunctor`, `Profunctor` and others?
part of the answer is: For historical reasons and to preserve backwards
The term "Functor", however, comes from category theory. MacLane 
defines the term "Functor" to refer to covariant functors. The notion
of "contravariant" is introduced via the concept of "opposite category"
 which has the same objects but direction of arrows reversed. Thus a
contravariant functor F: C -> D is just an ordinary functor C -> D^op.
Category theory has no name for the action of a functor on arrows,
Haskell had to make up a name, which ended up to be "fmap". Sometimes
the notation F(f) is used in category theory where in Haskell we write
fmap f. If I could re-define Haskell from scratch, I'd probably name
the Functor type class function 'map' and omit the map function on
lists, since it is the same as the Functor instance.
As for your suggestion of 'comap': The prefix co- in category theory is
mostly used in conjunction with the opposite construction , whence a
category theorist would believe 'comap' to mean the opposite of 'map'.
 Saunders MacLane: Categories for the Working Mathematician. ISBN 7-
 See Op in Data.Functor.Contravariant
 See categorical concepts like limit vs. colimit, cone vs. cocone.
More information about the Haskell-Cafe