Just a quickie:

I see that the fixity decl of the monad operation >> and >>= changed
from right associative in 1.3 to left associative in 1.4.  This strikes
me as a bug in 1.4 which ought to be reversed in 98.

Right associativity allows:
    f >>= \x->
    g >>= \y->
    h x
which with left associativity will be rejected because x is unbound
(in h x), or even worse: if x is bound at an outer scope, you might get
completely the wrong value (or if you're lucky a type error).

I haven't been able to find any archived messages motivating the
change for 1.4: am I missing something important?

I can only imagine two reasons for left associativity:
  1. To make the >>= syntax so horrible in the common case (by requiring
     brackets or $ signs) that everyone moves to `do' notation.  :-)
  2. To allow a sort of "unix pipeline" style of monadic composition,
     where the components don't have explicit lambdas:
        f >>= g >>= h >>= j
     I would argue that this is an infrequent style compared to the
     common case of my first example.  In any case, with the new (=<<)
     operator, the "pipeline" composition can easily be cast to look
     more like normal functional composition anyway,
        j =<< h =<< g =<< f
     removing the need for >>= to be left associative.

What do other people think?

Regards,
    Malcolm



Reply via email to