
C. McCann wrote:
Heinrich Apfelmus wrote:
Combined with >>= / >> you have multiple reading direction in the same expression, as in
expression ( c . b . a ) `liftM` a1 >>= a2 >>= a3 reading order 6 5 4 1 2 3
That's why I'm usually using =<< instead of >>= .
Does it bother you that (=<<) is defined to be infixr 1, while (<$>) and (<*>) are infixl 4? Or is that just me?
For instance, I might write the above expression as something like:
a3 =<< a2 =<< a . b . c <$> a1
But this still seems awkward, because it mixes different fixities and I have to mentally regroup things when reading it. Right associativity here does make a certain amount of sense for monads, but left-associativity is consistent with plain function application and feels more natural to me.
Well, you can't give (=<<) left fixity because its type doesn't allow it. (a3 =<< a2) =<< a1 -- ill-typed! So, (=<<) is modeled after (:) , not after (<$>) . Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com