
On 1/8/11 5:23 AM, C K Kashyap wrote:
Hi,
Thanks to Luke Palmer's explanation. I got a better idea of functors. I just want to ratify my understanding of what a functor is - according to category theory, functors are arrows between categories ... these arrows map objets and arrows from one category into another.
Yes, provided the mappings on objects and arrows behaves in the right way, namely preserving identities and compositions: F(id_A) = id_(FA) F(f.g) = F(f) . F(g) That is, functors are exactly category homomorphisms (i.e., mappings which preserve the categorical structure).
So, would it be right to say that the list type constructor + the map function form the functor? Saying "list is a functor then is a convenient approximation right?
Yes, the combination of the type constructor (mapping from types/objects to types/objects) and the fmap instance (mapping from functions/arrows to functions/arrows) together constitute the functor. Saying "list is a functor" is a common sloppiness just like saying "list is a monad". -- Live well, ~wren