[Haskell-cafe] Re: Re: A free monad theorem?

Tomasz Zielonka tomasz.zielonka at gmail.com
Sat Sep 2 18:26:25 EDT 2006

On Sat, Sep 02, 2006 at 09:51:26PM +0200, Benjamin Franksen wrote:
> However, in order to 'run' (i.e. finally actually use) a monadic value
> that involves an application of bind, the latter would have to supply
> some argument to its second argument (which is a function),

If I didn't see above, only the following text...

> so there must be some way to 'get an a out of' the first argument m.

I would answer: Yes, there is a method in Monad which has exactly this
purpose: >>=

I think I understand your confusion. Here are some non-controversial
statements that may help you:

>>= is meant to be the only generic, primitive way of passing result
from one monadic computation to another (there is also "join", but
Haskell chose to derive it from >>=). It is a class method exactly
because each monad should be able to use its own way of binding

Programmers define the >>= method for their monads because they want to
use it to bind computations. They know how to pass result(s) from
one computation in their Monad to another, and they put this algorithm
in the implementation of >>=. If they didn't care about passing results
from one computation to the next one, they wouldn't be using monads in
the first place.

Best regards

More information about the Haskell-Cafe mailing list