Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-19 Thread wren ng thornton
Hans van Thiel wrote: On Wed, 2009-06-17 at 21:26 -0500, Jake McArthur wrote: Jon Strait wrote: I'm reading the third (bind associativity) law for monads in this form: m = (\x - k x = h) = (m = k) = h Arguably, that law would be better stated as: (h = k) = m = h = (k = m) This

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Hans van Thiel
On Wed, 2009-06-17 at 21:26 -0500, Jake McArthur wrote: Jon Strait wrote: I'm reading the third (bind associativity) law for monads in this form: m = (\x - k x = h) = (m = k) = h Arguably, that law would be better stated as: (h = k) = m = h = (k = m) This wouldn't be so

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Jake McArthur
Hans van Thiel wrote: The only place I've ever seen Kleisli composition, or its flip, used is in demonstrating the monad laws. Yet it is so elegant and, even having its own name, it must have some practical use. Do you, or anybody else, have some pointers? I only just started finding places to

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Sjoerd Visscher
I had seen it before, and a bit of Googling turned up this: The monad laws can be written as return = g == g g = return == g (g = h) = k == g= (h = k) So, functions of type a - m b are the arrows of a category with (=) as composition, and return as identity.

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Jake McArthur
Jake McArthur wrote: Generally, you can transform anything of the form: baz x1 = a = b = ... = z x1 into: baz = a = b = ... = z I was just looking through the source for the recently announced Hyena library and decided to give a more concrete example from a real-world project.

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Colin Adams
What is enum2 doing in all of this - it appears to be ignored. 2009/6/18 Jake McArthur jake.mcart...@gmail.com: Jake McArthur wrote: Generally, you can transform anything of the form:    baz x1 = a = b = ... = z x1 into:    baz = a = b = ... = z I was just looking through the source

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Neil Brown
Clicking on the source code link reveals that enum2 is used in the where clause. It's not important to the transformation that Jake was performing. In essence, = is the monadic version of . (function composition) and as explained, it can be used to do some pointfree-like programming in the

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Hans van Thiel
On Thu, 2009-06-18 at 08:34 -0500, Jake McArthur wrote: [snip] So, `(=)` is just like `($)` except for the information carried along by the monad. Anyway, the obvious thing to do is to drop the `x` from both sides of the definition for `bar`. To do that with `foo` earlier, we had to

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Jake McArthur
Hans van Thiel wrote: Just to show I'm paying attention, there's an arrow missing, right? (.) ::(b - c) - (a - b) - (a - c) Correct. I noticed that after I sent it but I figured that it would be noticed. I also used () where I meant (=) at the bottom. They are

[Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-17 Thread Jon Strait
Hi everyone, I use and love Haskell, but I just have this nagging concern, that maybe someone can help me reason about. If I'm missing something completely obvious here and making the wrong assumptions, please be gentle. :) I'm reading the third (bind associativity) law for monads in this

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-17 Thread Dan Piponi
On Wed, Jun 17, 2009 at 6:08 PM, Jon Straitjstr...@moonloop.net wrote: ...but if there were another monad defined like, data MadMaybe a = Nothing | Perhaps | Just a MadMaybe violates the second law. It's quite unlike a monad. -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-17 Thread Jake McArthur
Jon Strait wrote: I'm reading the third (bind associativity) law for monads in this form: m = (\x - k x = h) = (m = k) = h Arguably, that law would be better stated as: (h = k) = m = h = (k = m) This wouldn't be so unintuitive. - Jake ___

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-17 Thread David Menendez
On Wed, Jun 17, 2009 at 9:08 PM, Jon Straitjstr...@moonloop.net wrote: I use and love Haskell, but I just have this nagging concern, that maybe someone can help me reason about.  If I'm missing something completely obvious here and making the wrong assumptions, please be gentle.  :) I'm