[Haskell-cafe] Functor and Haskell

Dan Weston westondan at imageworks.com
Tue Apr 21 21:40:07 EDT 2009

List is not a full subcategory of Hask, so it's a bad choice. Namely, 
types of functions on a list (e.g. [a] -> [a]) are not themselves lists 
of type [b] for some b, and so are not objects of List (though they are 
morphisms in it). In Hask, ([a] -> [a]) is both an object and a morphism 
(in fact, there is a unique object in Hask for every morphism).

It turns out (I believe) that the smallest subcategory that fits the 
Haskell Functor type class is Hask itself. That doesn't mean that the 
functor is epic: (Int -> Int) is not the type of (fmap f) for any f.

So C and D are the same category: Hask.

Take a look at:

Daryoush Mehrtash wrote:
> I am not sure I follow how the endofunctor gave me the 2nd functor.
> As I read the transformation there are two catagories C and D and two 
> functors F and G between the same two catagories.  My problem is that I 
> only have one functor between the Hask and List catagories.  So where 
> does the 2nd functor come into picture that also maps between the same C 
> and D catagories?
> Thanks
> Daryoush
> On Tue, Apr 21, 2009 at 4:01 PM, Dan Weston <westondan at imageworks.com 
> <mailto:westondan at imageworks.com>> wrote:
>     You are on the right track. The usual construction is that Hask is
>     the category (with types as objects and functions as morphisms).
>     Functor F is then an endofunctor taking Hask to itself:
>     a -> F a
>     f -> fmap f
>     So, for F = []:
>     a -> [a]
>     f -> map f
>     Natural transformations are then any fully polymorphic (no context)
>     unary function. The polymorphism is what makes them natural, since
>     there is no method to treat one object (type) different from another.
>     Daryoush Mehrtash wrote:
>         In category theory functors are defined between two category of
>         C and D where every object and morphism from C is mapped to D.
>         I am trying to make sense of the above definition with functor
>         class in Haskell.   Let say I am dealing with List type.  When I
>         define List to be a instance of a functor I am saying the source
>         category (C) is Haskell types and the destination category is
>         List (D).    In this the "fmap" is implementation of the mapping
>         between every morphism in my Haskell Categroy (C) to morphism in
>          List cataegory (D).   With type constructor I also have the
>         mapping of types (objects in Haskell Category, or my source
>         cataegroy C) to List category (D).  So my functor in the
>         catarogy sense is actually the fmap and type constructor.  Am I
>         remotely correct?
>         If this is correct.... With this example, then can you then help
>         me understand the transformation between functors and natural
>         transformations?     Specifically, what does it means to have
>         two different functors between Haskell cateogry and List category?
>         Thanks,
>         Daryoush

More information about the Haskell-Cafe mailing list