[Haskell-cafe] Re: Functor and Haskell

Ertugrul Soeylemez es at ertes.de
Tue Apr 21 19:43:17 EDT 2009


Daryoush Mehrtash <dmehrtash at gmail.com> 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?

The type constructors map objects from C to objects from F(C).  The
'fmap' function maps morphisms from C to morphisms from F(C).  You can
see this immediately by looking at the type of 'fmap' (note that (->) is
right-associative):

  fmap :: Functor f => (a -> b) -> (f a -> f b)


Greets,
Ertugrul.


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/




More information about the Haskell-Cafe mailing list