[Haskell-beginners] Functors in Haskell

Brent Yorgey byorgey at seas.upenn.edu
Tue Apr 29 19:22:36 UTC 2014


Right.  Note, your original formulation---saying that a Functor
instance maps from Hask to some subcategory of Hask (e.g. all types of
the form Maybe X) was not wrong.  It's just not a very useful way to
think about it; as Rein described it's more useful to think of Functor
instances as functors Hask -> Hask.

-Brent

On Tue, Apr 29, 2014 at 01:05:13PM -0600, Dimitri DeFigueiredo wrote:
> Wow, this makes it very clear!
> 
> So, the object mapping is provided by the type constructor and the
> arrow mapping by fmap.
> 
> Thanks :-)
> 
> 
> Em 29/04/14 12:35, Rein Henrichs escreveu:
> >Yes, this is reasonable, but it might be useful to be a bit more
> >explicit about the categories involved.
> >
> >An instance of Functor is a functor which maps objects and arrows
> >in the category of Hask (of Haskell types and functions) to...
> >objects and arrows in the category of Hask. It is an endofunctor.
> >The object mapping must map a type to a type and therefore must
> >have the kind * -> *. This means that it is a type constructor,
> >e.g., Maybe. The arrow mapping must map arrows to arrows, which
> >means it must map functions to functions. fmap provides this
> >mapping and the Functor laws in Haskell are of course equivalent to
> >the laws from category theory.
> >
> >And while the inclusion of bottom is problematic for Hask, it is
> >still possible to reason about it in a "morally correct" way (http://www.cse.chalmers.se/~nad/publications/danielsson-et-al-popl2006.pdf <http://www.cse.chalmers.se/%7Enad/publications/danielsson-et-al-popl2006.pdf>).
> >
> >
> >_______________________________________________
> >Beginners mailing list
> >Beginners at haskell.org
> >http://www.haskell.org/mailman/listinfo/beginners
> 

> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list