[Haskell-cafe] Join and it's relation to >>= and return

Iavor S. Diatchki diatchki at cse.ogi.edu
Tue Jun 8 17:50:03 EDT 2004

hi ron,

here are the relations between the two formulations of monads:
(using haskell notation)

map f  m     = m >>= (return . f)
join m         = m >>= id

m >>= f      = join (fmap f m)

there are quite a few general concepts that you need
to understand in what sense monads are monoids, but
to understand how monads work you don't need to know that.

Ron de Bruijn wrote:

>I am pretty sure, that >>= is to monads what * is to
>for example natural numbers, but I don't know what the
>inverse of >>= is. And I can't really find it anywhere
>on the web(papers, websites, not a single sole does
>mention it. 
this is not quie correct.  (join & return) for a monad are like
(*,1) or (+,0) for the set of integers.  however those operations on
integers have more structure than join and return.

there is no operation for "inverse". in mathematical terms:
monads are a monoid (given that the notion is generalized considerably
from its usual use), and not a group. 
if one was to add such an operation
(i am not sure what it would do), but it would be of type:
inverse :: M a -> M a (and of course must satisfy some laws)

also while you are pondering these things, it may be useful to use
the "backward join" (=<<) :: (a -> m b) -> (m a -> m b).
the reason for that is that strictly speaking tha arrow in the middle
is different from the left and the right arrows

i am not sure how useful this information is for you,
but if you have more questions ask away

>It should have type, at least that's what I think:
>inv::M a->M b
>I say this, because I find this definition of a
>multiplication operation:
>   1. There exists a unique special element called
>neutral such that the operation on any element and the
>neutral does not change the element.
>   2. For every element there exists an inverse such
>that the operation on an element and its inverse is
>always neutral.
>   3. The operation is associative: it does not matter
>how you apply the operation to three elements. You may
>apply it to the first two and then to the result and
>the third element. Or you may first apply the
>operation to the last two and then to the first and
>the result of the previous operation. 
>An operation may also be commutative
>   4. The order of two elements in operation is not
>According to 2 there should be an inverse. For join
>such an inverse is simple: to apply the type
>constructor on the monad. But I tried to somehow link
>it with bind, but than the types don't seem to match.
>So to be concrete: what's the inverse of bind? 
>If I did make some errors, please tell me so. 
>Do you Yahoo!?
>Friends.  Fun.  Try the all-new Yahoo! Messenger.
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org

More information about the Haskell-Cafe mailing list