[Haskell-cafe] Functor and Haskell
dmehrtash at gmail.com
Thu Apr 23 16:07:42 EDT 2009
Thanks this was helpful.
In many of Conal Elliot's writings I see that he shows that his semantic
function is a natural transformation. Is that just basically showing the
polymorphic nature of his semantic functions, or are there other benifits
you get by showing a particular function is a natural transformation?
On Thu, Apr 23, 2009 at 12:34 PM, Dan Doel <dan.doel at gmail.com> wrote:
> On Thursday 23 April 2009 2:44:48 pm Daryoush Mehrtash wrote:
> > 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
> > transformation can also be view as a simple morphism too. In this
> > the listToMaybe can be viewed as morphism between list and Maybe types
> > are both in the Hask categroy too. right? If so then what would
> > the morphism as natural transformation by you?
> listToMaybe in general wouldn't be a morphism in the category, because
> morphisms would be from concrete types to other concrete types.  So, if
> you'll excuse some notation I just made up (with a little help from GHC
> notation :)):
> listToMaybe at Int :: [Int] -> Maybe Int
> listToMaybe at Char :: [Char] -> Maybe Char
> listToMaybe at String :: [String] -> Maybe String
> are all morphisms in the alleged Hask category. Each polymorphic function
> (similar to the above one, at least) defines a family of morphisms like
> *But*, that's what a natural transformation is: a family of morphisms, one
> each object in the category, that commute with functor application in a
> certain way. Thus, one can look at the fully polymorphic listToMaybe as a
> natural transformation:
> listToMaybe ::  -> Maybe
> -- Dan
>  Maybe you could make up a category where polymorphic types are objects
> well, but that doesn't seem to be the way people typically go about
> category theory to Haskell.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe