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!)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With