On 07/20/2013 12:58 AM, Matt Ford wrote:
Hi,
Thanks for the help.
I thought >>= was left associative? It seems to be in the examples from
Learn You A Haskell.
...
Yes, >>= is left-associative. The associativity of >>= is not relevant
for your example because no two >>= operations actually occur next to
each other. The second >>= is part of the lambda occurring as the second
argument to the first >>=. Lambdas bind 'the rest of the expression'.
[1,2] >>= \n -> [3,4] >>= \m -> return (n,m)
is equivalent to:
let a = [1,2]
b = (\n -> [3,4] >>= \m -> return (n,m))
in a >>= b
I tried to use the associative law to bracket from the right but it
didn't like that either...
[1,2] >>= (\x -> (\n -> [3,4])) x >>= \m -> return (n,m))
Any thoughts?
...
Where does that 'x' come from?
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe