Re: [Haskell-cafe] Functor and Haskell

2009-04-24 Thread wren ng thornton
Daryoush Mehrtash wrote: 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

Re: [Haskell-cafe] Functor and Haskell

2009-04-23 Thread Daryoush Mehrtash
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

Re: [Haskell-cafe] Functor and Haskell

2009-04-23 Thread Dan Doel
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 functor transformation can also be view as a simple morphism too. In this example the

Re: [Haskell-cafe] Functor and Haskell

2009-04-23 Thread Daryoush Mehrtash
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

Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Kim-Ee Yeoh
Daryoush Mehrtash-2 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

Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Daryoush Mehrtash
Here F is the identity functor, and G is the list functor. And yes, C=D= category of (a subset of) Haskell types. Are you saying the function that goes from list functor to singleton funtor is a natural transformation? But aren't they functors to different subset of Haskell Types? The Haskell

Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread 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,

Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Kim-Ee Yeoh
Daryoush Mehrtash-2 wrote: singleton :: a - [a] singleton x = [x] Here F is the identity functor, and G is the list functor. And yes, C=D= category of (a subset of) Haskell types. Are you saying the function that goes from list functor to singleton funtor is a natural

[Haskell-cafe] Functor and Haskell

2009-04-21 Thread Daryoush Mehrtash
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

Re: [Haskell-cafe] Functor and Haskell

2009-04-21 Thread Dan Weston
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

Re: [Haskell-cafe] Functor and Haskell

2009-04-21 Thread Daryoush Mehrtash
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

Re: [Haskell-cafe] Functor and Haskell

2009-04-21 Thread Dan Weston
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,

Re: [Haskell-cafe] Functor and Haskell

2009-04-21 Thread wren ng thornton
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.