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

Joseph Abrahamson me at jspha.com
Thu Dec 11 20:46:54 UTC 2014


I think after discussion I’m -1 on any implementation thus discussed.




I think I’d be happiest if we had Monad(return, bind) with `bind :: (a -> m b) -> (m a -> m b)` and `(>>=) = flip bind`, but that’s pretty infeasible. : )

On Thu, Dec 11, 2014 at 3:30 PM, Edward Kmett <ekmett at gmail.com> wrote:

> My sentiments are very similiar here.
> I find myself a weak -1 on this, because "bind" has the flipped semantics
> to many folks, joinMap is ugly and far longer than the alternative, (=<<)
> already exists, it becomes a fresh way to confuse users with monadic
> syntax, and it takes another precious name from the namespace.
> The analogies for fmap and ap strike me as false equivalences, fmap came
> long before the applicative sugar for (<$>), the same with ap, which long
> predates (<*>), and which serves canonically as a default definition for it.
> -Edward
> On Thu, Dec 11, 2014 at 3:43 AM, Andreas Abel <andreas.abel at ifi.lmu.de>
> wrote:
>> On 10.12.2014 17:33, John Lato wrote:
>>
>>> I don't really understand why people want this. What's wrong with (=<<)
>>> ?  I kind of feel like a named function should be no longer than that.
>>>
>>
>> You are right, we do not need a alphabetic version of every operator. We
>> do not have
>>
>>   plus = (+)
>>
>> either.  Why take another good name from the user, just to avoid using an
>> operator in parentheses?
>>
>> I am -1 on the whole business here.
>>
>> Cheers,
>> Andreas
>>
>>
>>> I don't object, especially if others think it's useful (and many clearly
>>> do), but I guess it's not to my taste.
>>>
>>>
>>> On 08:02, Wed, Dec 10, 2014 David Feuer <david.feuer at gmail.com
>>> <mailto:david.feuer at gmail.com>> wrote:
>>>
>>>     joinMap looks to me like the best name, because it does just what it
>>>     says on the box:
>>>
>>>     join . fmap f $ m
>>>     = (m >>= return . f) >>= id --Functor/Monad law
>>>     = m >>= (\x -> return (f x) >>= id) --associativity
>>>     = m >>= (\x -> f x) --left identity
>>>     = m >>= f --eta reduction
>>>     = f =<< m
>>>
>>>     Christopher Done <chrisdone at gmail.com <mailto:chrisdone at gmail.com>>
>>>
>>>     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
>>>
>>>     _______________________________________________
>>>     Libraries mailing list
>>>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>>>     http://www.haskell.org/mailman/listinfo/libraries
>>>
>>>     _________________________________________________
>>>     Libraries mailing list
>>>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>>>     http://www.haskell.org/__mailman/listinfo/libraries
>>>     <http://www.haskell.org/mailman/listinfo/libraries>
>>>
>>>
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://www.haskell.org/mailman/listinfo/libraries
>>>
>>>
>>
>> --
>> Andreas Abel  <><      Du bist der geliebte Mensch.
>>
>> Department of Computer Science and Engineering
>> Chalmers and Gothenburg University, Sweden
>>
>> andreas.abel at gu.se
>> http://www2.tcs.ifi.lmu.de/~abel/
>> _______________________________________________
>> 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/20141211/9315dc6a/attachment.html>


More information about the Libraries mailing list