Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-17 Thread Roberto Zunino
Dominic Steinitz wrote: Roberto Zunino wrote: This is the point: eta does not hold if seq exists. undefined `seq` 1 == undefined (\x - undefined x) `seq` 1 == 1 Ok I've never used seq and I've never used unsavePerformIO. Provided my program doesn't contain these then can I assume that eta

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-17 Thread Corey O'Connor
Excellent! This has all been very helpful. Thanks a lot everybody! :-) -Corey On 12/14/07, Benja Fallenstein [EMAIL PROTECTED] wrote: Hi Corey, On Dec 14, 2007 8:44 PM, Corey O'Connor [EMAIL PROTECTED] wrote: The reason I find all this odd is because I'm not sure how the type class Functor

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds extra laziness. Use this Do you have a counter-example of (.) not being function composition in the categorical sense? ___

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By definition, (.) = \ f - \ g - \ x - f (g x) Then bot . id = ((\ f - \ g - \ x - f (g x)) bot) id = (\ g - \ x

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Roberto Zunino
Yitzchak Gale wrote: When using seq and _|_ in the context of categories, keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds extra laziness. Use this instead: (.!) f g x = f `seq` g `seq` f (g x) id .! undefined == \x -

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Roberto Zunino
Dominic Steinitz wrote: This would give = \x - bot x and by eta reduction This is the point: eta does not hold if seq exists. undefined `seq` 1 == undefined (\x - undefined x) `seq` 1 == 1 The (.) does not form a category argument should be something like: id . undefined == (\x -

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Yitzchak Gale
I wrote: (.!) f g x = f `seq` g `seq` f (g x) Roberto Zunino wrote: id .! undefined == \x - undefined /= undefined Probably you meant (.!) f g = f `seq` g `seq` (f . g) Yes, thank you. -Yitz ___ Haskell-Cafe mailing list

Re: Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread jerzy . karczmarczuk
Roberto Zunino writes: without seq, there is no way to distinguish between undefined and (const undefined), no way to distinguish is perhaps too strong. They have slightly different types. Jerzy Karczmarczuk ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Roberto Zunino wrote: Dominic Steinitz wrote: This would give = \x - bot x and by eta reduction This is the point: eta does not hold if seq exists. undefined `seq` 1 == undefined (\x - undefined x) `seq` 1 == 1 Ok I've never used seq and I've never used unsavePerformIO.

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Jonathan Cast wrote: On 16 Dec 2007, at 3:21 AM, Dominic Steinitz wrote: Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By definition, (.) = \ f - \ g - \ x - f (g x)

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-15 Thread Yitzchak Gale
Ah, good old seq. How I loathe it. Seriously, though, good catch. I always forget about seq when I'm doing stuff like this. When using seq and _|_ in the context of categories, keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds

[Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Corey O'Connor
I'm working through the interesting paper Data type à la carte and am confused by the Functor instance for Val. I think this stems from some confusion of mine regarding the Functor class in general. The Functor instance I'm confused about is: instance Functor Val where fmap f (Val x )

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Philip Weaver
On Dec 14, 2007 11:44 AM, Corey O'Connor [EMAIL PROTECTED] wrote: I'm working through the interesting paper Data type à la carte and am confused by the Functor instance for Val. I think this stems from some confusion of mine regarding the Functor class in general. I'll try to explain, but I

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Benja Fallenstein
Hi Corey, On Dec 14, 2007 8:44 PM, Corey O'Connor [EMAIL PROTECTED] wrote: The reason I find all this odd is because I'm not sure how the type class Functor relates to the category theory concept of a functor. How does declaring a type constructor to be an instance of the Functor class relate

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Felipe Lessa
On Dec 14, 2007 6:37 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: such that the following two properties hold: * F(idX) = idF(X) for every object X in C * F(g . f) = F(g) . F(f) for all morphisms f:X - Y and g:Y - Z. Should we write instance Functor Val where fmap = undefined

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Felipe Lessa
On Dec 15, 2007 12:00 AM, David Menendez [EMAIL PROTECTED] wrote: These can (and, if Val is a newtype, will) be compiled to the same code, but they don't have the same type. In particular, there is no way to unify a - a with f a - f b for any f. Thanks for noticing that! I hadn't seen before

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Ryan Ingram
On 12/14/07, David Menendez [EMAIL PROTECTED] wrote: And yes, I'm pretty sure that's the only possible implementation for that type which satisfies the functor laws. Lets just prove it, then; I'm pretty sure it comes pretty easily from the free theorem for the type of fmap. data Val a =

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Benja Fallenstein
On Dec 15, 2007 3:44 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: Hmmm. Something about that ticks off my don't play fast and loose with bottom detector. I should add that I do think you're correct if you ignore the existence of bottom, and I'm pretty sure that you're correct if you allow

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread David Menendez
On Dec 14, 2007 9:44 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: data Val a = Val Int instance Functor Val where fmap f (Val x) = f `seq` Val x Ah, good old seq. How I loathe it. Seriously, though, good catch. I always forget about seq when I'm doing stuff like this. -- Dave