9

I’ve been playing with Haskell on and off for several years now; I’m quite comfortable with how monads work, and how to use them, and what the operators (=<<) and (>>=) do.

But I still don’t know how to talk about them! Is there any standard term for what they do — for the action of transforming an arrow a -> m b into an arrow m a -> m b?

(As a mathematician by background, one option that springs to mind is “the forgetful functor from the Kleisli category”. But Haskell gurus must surely have some more succinct term, since in Haskell, this operation is used as one of the building blocks of monads, unlike in the mathematical setting where it’s usually considered as a derived operation, defined from multiplication together with functoriality!)

PLL
  • 1,572
  • 1
  • 13
  • 21
  • 6
    The general term for `>>=` is `bind`, as this was used in Wadler's *The essence of functional programming* paper which introduced them in Haskell (Not sure if the term was used prior to this). – Mark H Dec 22 '13 at 14:41
  • Ah, thankyou very much! If you make that an answer, I’ll accept it. – PLL Dec 22 '13 at 14:41
  • Actually, as Haskell keeps solidifying its way of doing category theory, there's a trend towards starting from `join` rather than `>>=`. But sure, _bind_ is just more convenient in most practical applications. – leftaroundabout Dec 22 '13 at 16:23
  • 1
    Possible duplicate of [Are there pronouncable names for common Haskell operators?](http://stackoverflow.com/q/7746894/3015232) – not my job Dec 23 '13 at 09:09
  • Does this answer your question? [Are there pronounceable names for common Haskell operators?](https://stackoverflow.com/questions/7746894/are-there-pronounceable-names-for-common-haskell-operators) – cigien Nov 14 '20 at 00:52

1 Answers1

9

The official name for >>= is bind. We can also read it as "feed through", "process by", etc. Brian Benkman from MSDN's Channel 9 calls it "shove" (to the right, or to the left).

Why bind? By analogy with let. Just as let binds its variables to results of evaluating the initial expressions, the "monadic let" would "bind" its variables to results of its input computations:

let a = ....      or:      .... $>> (\ a ->      -- non-recursive "let", as in Lisp,
    b = ....               .... $>> (\ b ->      --    (Haskell's is Lisp's "letrec")
in  ....                   .... ))             where x $>> f = f x


do a <- ....      or:      .... >>= (\ a ->
   b <- ....               .... >>= (\ b ->
   ....                    .... ))

This is, as you can see, from completely non-mathematical, practical perspective.

Will Ness
  • 70,110
  • 9
  • 98
  • 181