3 ms·
You're right, there's no right-associativity actually involved, but the article probably used the term because the code kinda looks right-associative if you squ
by Sharlin 3y ago
You're right, there's no right-associativity actually involved, but the article probably used the term because the code kinda looks right-associative if you squint. The point is that the rightmost >>= is evaluated first, which lets the y lambda capture x. The article put the parens like this:
test3 = [1, 2] >>= (\x -> [x, 10*x] >>= \y -> [x*y])
which to a non-Haskeller like me does make it look more right-associative than it actually is – and as the article showed, you can actually make it "left-associative" in the obvious way, which would indeed compile fine and be equivalent to the "right-associative" way if the y lambda didn't refer to x.
test3 = ([1, 2] >>= \x -> [x, 10*x]) >>= \y -> [x*y]