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

Christopher Allen cma at bitemyapp.com
Tue Dec 9 21:59:19 UTC 2014


Sorry, if that wasn't obvious, that was a +1.

On Tue, Dec 9, 2014 at 3:59 PM, Christopher Allen <cma at bitemyapp.com> wrote:

> I'd love to have a "bind" with that nice symmetry with fmap for both
> personal use and for pedagogical purposes. I use precisely that function by
> that name to help teach monads already.
>
> On Tue, Dec 9, 2014 at 3:55 PM, Bob Ippolito <bob at redivi.com> wrote:
>
>> +1 from me, I would love to have named versions of these operators.
>>
>> Does `ap` still have a Monad constraint or has it been changed to match
>> the Applicative `<*>` after AMP?
>>
>> On Tue, Dec 9, 2014 at 1:44 PM, Christopher Done <chrisdone at gmail.com>
>> wrote:
>>
>>> 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 = (=<<)
>>>
>>> For comparison, the not-very-pleasant <$> and <*> each have word
>>> alternatives, fmap and ap. Even <> has mappend.
>>>
>>> I don’t hold much hope for this, Haskellers love operators as much as
>>> Perl programmers so few on this list will see the value in plain old
>>> words, but at least I can link to this email in the archives for
>>> future reference.
>>>
>>> Ciao
>>>>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://www.haskell.org/mailman/listinfo/libraries
>>>
>>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141209/7b259f8c/attachment-0001.html>


More information about the Libraries mailing list