[Haskell-cafe] Re: Who is afraid of arrows, was Re: ANNOUNCE:
Haskell XML Toolbox Version 9.0.0
C. McCann
cam at uptoisomorphism.net
Wed Oct 13 10:05:38 EDT 2010
On Wed, Oct 13, 2010 at 3:50 AM, Heinrich Apfelmus
<apfelmus at quantentunnel.de> 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.
- C.
More information about the Haskell-Cafe
mailing list