
Thanks for this example I get the point now. (at least i think i do :) )
One more question.... This all being on the same category then the functor
transformation can also be view as a simple morphism too. In this example
the listToMaybe can be viewed as morphism between list and Maybe types that
are both in the Hask categroy too. right? If so then what would viewing
the morphism as natural transformation by you?
Thanks,
Daryoush
P.S. for others interested in the same topic I found this on Haskell wikis
that add some more detail:
http://www.haskell.org/haskellwiki/Category_theory/Natural_transformation
On Wed, Apr 22, 2009 at 3:40 PM, Ross Paterson
On Wed, Apr 22, 2009 at 03:14:03PM -0700, Daryoush Mehrtash wrote:
The Haskell Wikibooks also says the same thing:
Functors in Haskell are from Hask to func, where func is the subcategory of Hask defined on just that functor's types. E.g. the list functor goes from Hask to Lst, where Lst is the category containing only list types, that is, [T] for any type T. The morphisms in Lst are functions defined on list types, that is, functions [T] -> [U] for types T, U.
That's true, but not a particularly helpful view. Any functor F : C -> D can be viewed as a functor from C to the full subcategory of D on objects of the form F A for A an object of C. But then different functors map to different categories and you can't talk about natural transformations between them. Composing functors also becomes impossible.
The simple view is that [], Maybe and Id are all functors from Hask to Hask. Then listToMaybe :: [a] -> Maybe a is a natural transformation from [] to Maybe, because
fmap f . listToMaybe = listToMaybe . map f _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe