[Haskell-cafe] (Co/Contra)Functor and Comonad

wren ng thornton wren at freegeek.org
Sat Dec 25 01:25:30 CET 2010


On 12/23/10 11:46 PM, Mario Blažević wrote:
> On Thu, Dec 23, 2010 at 11:25 PM, Tony Morris<tonymorris at gmail.com>  wrote:
>>
>> ...regardless of the utility of a contravariant functor type-class, I
>> strongly advocate for calling it Contrafunctor and not Cofunctor. I
>> have seen numerous examples of confusion over this, particularly in
>> other languages.
>
> I don't personally care what's it called, as long as it's available. Can
> anybody point to an authoritative source for the terminology, though?
> Wikipedia claims that cofunctor is a contravariant functor.

Cofunctor = Functor.

That is, given a functor F : C -> D, the dual is F^op : C^op -> D^op. On 
objects this is defined by F^op(X) = (F X)^op, which is equal to F X 
since duality doesn't change objects. And on morphism it's defined by 
F^op(f) = (F f^op)^op, but since f comes from C^op this is exactly the 
same thing as F^op(g^op) = (F g)^op where g is in C. So taking the dual 
of g and applying F^op is the same as applying F and then taking the 
dual. Thus, F^op is essentially identical to F and does the exact same 
thing. It just happens to have a slightly different type since it's the 
dual copy that lives on the other half of Cat.


Whereas contravriant functors are those functors that can be visualized 
as some F : C -> D^op (or F : C^op -> D if you prefer; just as functor = 
cofunctor, so too contrafunctor = co-contrafunctor). Contravariant 
functors are "just functors" from a categorical perspective, though we 
tend to prefer thinking of them as some action between C and D instead 
of between one of those and the dual of the other.

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list