bind :: Monad m => (a -> m b) -> m a -> m b

Oliver Charles ollie at
Wed Dec 10 09:02:04 UTC 2014

Christopher Done <chrisdone at> writes:

> Is this defined anywhere in base, and if not could it be placed in
> Control.Monad? I often find myself writing:
> fmap (mu bar)
>      (foo zot)
> Then I decide to change the type of x, so instead I want to just
> write:
> bind (mu bar)
>      (foo zot)
> Which is just like fmap but the function can run in the
> monad. Similar to traverse:
> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
> As someone who isn’t a fan of operators, I generally am appreciative
> of alternative regular plain English word versions of functions, which
> I find easier to type, read and edit. Currently without defining such
> a handy name, I have to transform the code to this:
> mu bar =<<foo zot
> The name for this function is a no-brainer:
> bind :: Monad m => (a -> m b) -> m a -> m bbind = (=<<)

I'm -1 on the *name* `bind`, because as others have mentioned, I feel bind
has the same type as (>>=).

That said, I'm +1 on the *idea* - if we can find a better name. `joinMap`
doesn't seem too bad, as was recently suggested, but I'll settle on
anything other than `bind`

-- ocharles
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <>

More information about the Libraries mailing list