Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Brent Yorgey
On Fri, Nov 30, 2012 at 02:33:54AM +0100, Ben Franksen wrote: Brent Yorgey wrote: On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote: Tony Morris wrote: As a side note, I think a direct superclass of Functor for Monad is not a good idea, just sayin' class Functor f

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Dan Doel
Lists! The finite kind. This could mean Seq for instance. On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu wrote: On Fri, Nov 30, 2012 at 02:33:54AM +0100, Ben Franksen wrote: Brent Yorgey wrote: On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote: Tony Morris

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Gershom Bazerman
On 11/30/12 10:44 AM, Dan Doel wrote: Lists! The finite kind. This could mean Seq for instance. On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu mailto:byor...@seas.upenn.edu wrote: Any data type which admits structures of arbitrary but *only finite* size has a natural

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Ben Franksen
Gershom Bazerman wrote: On 11/30/12 10:44 AM, Dan Doel wrote: Lists! The finite kind. This could mean Seq for instance. On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu mailto:byor...@seas.upenn.edu wrote: Any data type which admits structures of arbitrary but *only

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Kim-Ee Yeoh
Ben, Now, on to Bind: the standard finite structure example for Bind is most probably the substitution thingy ... Danger of conflating a bunch of things here: (1) the substitution monadic effect is always also applicative and always also unital/pointed because monads are always applicative and

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-29 Thread Brent Yorgey
On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote: Tony Morris wrote: As a side note, I think a direct superclass of Functor for Monad is not a good idea, just sayin' class Functor f where fmap :: (a - b) - f a - f b class Functor f = Apply f where (*) :: f (a -

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-29 Thread Ben Franksen
Brent Yorgey wrote: On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote: Tony Morris wrote: As a side note, I think a direct superclass of Functor for Monad is not a good idea, just sayin' class Functor f where fmap :: (a - b) - f a - f b class Functor f = Apply f

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-28 Thread Ben Franksen
Tony Morris wrote: As a side note, I think a direct superclass of Functor for Monad is not a good idea, just sayin' class Functor f where fmap :: (a - b) - f a - f b class Functor f = Apply f where (*) :: f (a - b) - f a - f b class Apply f = Bind f where (=) :: (a - f b) - f a

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-28 Thread Ben Franksen
Dan Doel wrote: On Tue, Oct 16, 2012 at 10:37 AM, AUGER Cédric sedri...@gmail.com wrote: join IS the most important from the categorical point of view. In a way it is natural to define 'bind' from 'join', but in Haskell, it is not always possible (see the Monad/Functor problem). As I said,

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-24 Thread Tony Morris
As a side note, I think a direct superclass of Functor for Monad is not a good idea, just sayin' class Functor f where fmap :: (a - b) - f a - f b class Functor f = Apply f where (*) :: f (a - b) - f a - f b class Apply f = Bind f where (=) :: (a - f b) - f a - f b class Apply f =

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-24 Thread AUGER Cédric
Le Wed, 24 Oct 2012 12:36:52 +0700, Kim-Ee Yeoh k...@atamo.com a écrit : On Tue, Oct 16, 2012 at 9:37 PM, AUGER Cédric sedri...@gmail.com wrote: As I said, from the mathematical point of view, join (often noted μ in category theory) is the (natural) transformation which with return (η

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-24 Thread Alberto G. Corona
What hiders according with my experience, the understanding of this generalization are some mistakes. two typical mistakes from my side was to consider an arrow as a function, and the consideration of m as a kind of container, which it is not from the point of view of category theory. a - m b

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-24 Thread Alberto G. Corona
The particular case from which the former is a generalization: *instance Monad m = Monoid (a - a) where* *mappend = (.)* *mempty = id* * * Here the monoid is defined for the functions within the set of values of type a. There are no null elements. 2012/10/24 Alberto G. Corona

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-23 Thread Kim-Ee Yeoh
On Tue, Oct 16, 2012 at 9:37 PM, AUGER Cédric sedri...@gmail.com wrote: As I said, from the mathematical point of view, join (often noted μ in category theory) is the (natural) transformation which with return (η that I may have erroneously written ε in some previous mail) defines a monad

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-22 Thread Andreas Abel
When I teach my students Haskell's monads, I never put Kleisli into my mouth. I tell them that monads are for sequencing effects; and the sequencing is visible clearly in () :: IO a - IO b - IO b (=) :: IO a - (a - IO b) - IO b but not in fmap :: (a - b) - IO a - IO b join :: IO

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread Jake McArthur
On Mon, Oct 15, 2012 at 11:29 PM, Dan Doel dan.d...@gmail.com wrote: I'm uncertain where this, compositional means written as the composition of functions, thing started. But it is not what I, and I'm sure any others mean by the term, compositional. You're right. It's a rather recent, as far

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread AUGER Cédric
Le Tue, 16 Oct 2012 07:35:34 +0530, damodar kulkarni kdamodar2...@gmail.com a écrit : @Jake In my opinion, this is not as nice as the do-notation version, but at least it's compositional: That's an important point you have made, as Haskellers value code composition so much. If code

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread AUGER Cédric
Le Tue, 16 Oct 2012 09:51:29 -0400, Jake McArthur jake.mcart...@gmail.com a écrit : On Mon, Oct 15, 2012 at 11:29 PM, Dan Doel dan.d...@gmail.com wrote: I'd be down with putting join in the class, but that tends to not be terribly important for most cases, either. Join is not the most

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread Daniel Peebles
Although I agree that Functor should be a superclass of Monad, the two methods of the Monad typeclass _are_ sufficient to make any instance into a Functor in a mechanical/automatic way. The language may not know it, but return/bind is equivalent in power to fmap/return/join. Apart from bind being

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread AUGER Cédric
Le Tue, 16 Oct 2012 11:22:08 -0400, Daniel Peebles pumpkin...@gmail.com a écrit : Although I agree that Functor should be a superclass of Monad, the two methods of the Monad typeclass _are_ sufficient to make any instance into a Functor in a mechanical/automatic way. The language may not know

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread Dan Doel
On Tue, Oct 16, 2012 at 10:37 AM, AUGER Cédric sedri...@gmail.com wrote: join IS the most important from the categorical point of view. In a way it is natural to define 'bind' from 'join', but in Haskell, it is not always possible (see the Monad/Functor problem). As I said, from the

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread AUGER Cédric
Le Tue, 16 Oct 2012 11:58:44 -0400, Dan Doel dan.d...@gmail.com a écrit : On Tue, Oct 16, 2012 at 10:37 AM, AUGER Cédric sedri...@gmail.com wrote: join IS the most important from the categorical point of view. In a way it is natural to define 'bind' from 'join', but in Haskell, it is not

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread Brandon Allbery
On Tue, Oct 16, 2012 at 1:19 PM, AUGER Cédric sedri...@gmail.com wrote: What do you mean by demonstrate? If you do not want to fit the mathematical presentation, then I have nothing to demonstrate, you have your point of view, I have mine and they differ. Now, if you want to I think the

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread David Thomas
I think the version below (with a Functor or Applicative superclass) is clearly the right answer if we were putting the prelude together from a clean slate. You can implement whichever is easiest for the particular monad, use whichever is most appropriate to the context (and add optimized

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-16 Thread Simon Thompson
Not sure I really have anything substantial to contribute, but it's certainly true that if you see a - m b as a generalisation of the usual function type, a - b, then return generalises the identity and kleisli generalises function composition. This makes the types pretty memorable (and

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread Ertugrul Söylemez
damodar kulkarni kdamodar2...@gmail.com wrote: The Monad class makes us define bind (=) and unit (return) for our monads. Why the Kleisli composition (=) or (=) is not made a part of Monad class instead of bind (=)? Is there any historical reason behind this? The bind (=) is not as

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread Benjamin Franksen
Ertugrul Söylemez wrote: damodar kulkarni kdamodar2...@gmail.com wrote: The Monad class makes us define bind (=) and unit (return) for our monads. Why the Kleisli composition (=) or (=) is not made a part of Monad class instead of bind (=)? Is there any historical reason behind this? The

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread AUGER Cédric
Le Mon, 15 Oct 2012 15:12:28 +0200, Benjamin Franksen benjamin.frank...@helmholtz-berlin.de a écrit : Ertugrul Söylemez wrote: damodar kulkarni kdamodar2...@gmail.com wrote: The Monad class makes us define bind (=) and unit (return) for our monads. Why the Kleisli composition (=) or

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread Jake McArthur
On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez e...@ertes.de wrote: Try to express do x - getLine y - getLine print (x, y) using only Kleisli composition (without cheating). In my opinion, this is not as nice as the do-notation version, but at least it's

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread Jake McArthur
On Mon, Oct 15, 2012 at 11:33 AM, Jake McArthur jake.mcart...@gmail.com wrote: On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez e...@ertes.de wrote: Try to express do x - getLine y - getLine print (x, y) using only Kleisli composition (without cheating). My previous

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread damodar kulkarni
@Jake In my opinion, this is not as nice as the do-notation version, but at least it's compositional: That's an important point you have made, as Haskellers value code composition so much. If code composition is the holy grail, why not encourage the monadic code, too, to be compositional?

Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-15 Thread Dan Doel
On Mon, Oct 15, 2012 at 10:05 PM, damodar kulkarni kdamodar2...@gmail.com wrote: @Jake In my opinion, this is not as nice as the do-notation version, but at least it's compositional: That's an important point you have made, as Haskellers value code composition so much. If code