
13 May
2008
13 May
'08
4:28 p.m.
2008/5/13 Abhay Parvate
Yes, I had always desired that the operator >>= should have been right associative for this short cut even when written without the 'do' notation.
You pretty much always want "a >>= b >>= c" to parse as "(a >>= b) >>=
c" and not "a >>= (b >>= c)". In the latter case, the two uses of
(>>=) aren't in the same monad.
You can get desired effect with the Kleisli composition operator
(>=>), which is in recent versions of Control.Monad. Unfortunately, it
has the same precedence as (>>=), so you can't use them together
without parentheses.
Using it, "a >>= b >>= c" can be rewritten "a >>= (b >=> c)" which is
short for "a >>= \x -> b x >>= c".
--
Dave Menendez