[Haskell-beginners] Monad and bind operator interpretation

Theodore Lief Gannon tanuki at gmail.com
Mon Dec 14 22:04:57 UTC 2015


Yeah, after my first couple of significant Haskell projects I came to the
conclusion that having (>>=) instead of (=<<) as the "canonical bind" is a
wart. (>>=) makes for clean desugaring of do notation, but obscures that (a
-> m b) -> (m a -> m b) intuition, which I think is more important
pedagogically and also tends to be cleaner in non-do monadic  code.

To a beginner, flip is an easy mechanical concept, but analyzing the
resultant type for new insights is not a habit yet. The one whose purpose
is purely mechanical should be "the flipped one."
On Dec 14, 2015 10:41 AM, "Joel Williamson" <joel.s.williamson at gmail.com>
wrote:

> This function is actually in the Prelude as (=<<).
>
> On Mon, 14 Dec 2015, 13:17 Dániel Arató <exitconsole at gmail.com> wrote:
>
>> On 14/12/2015, Raja <rajasharan at gmail.com> wrote:
>> > So extending this interpretation - can I swap the two parameters (?)
>> >
>> > Now my new hypothetical interpretation becomes:
>> >
>> > (>>=) :: (a -> m b) -> m a -> m b
>>
>> Sure,
>> bind' :: Monad m => (a -> m b) -> m a -> m b
>> bind' = flip (>>=)
>>
>> > If i further add parens:
>> >
>> > (>>=) :: (a -> m b) -> (m a -> m b)
>>
>> Yeah, that's exactly the same thing. Types are right associative.
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151214/0ce1bf0a/attachment-0001.html>


More information about the Beginners mailing list