The following line works as expected, but I am a little concerned why:
getLine >>= \x-> getLine >>= \y-> return [x, y]
Consider the addition of parenthesis to scope the lambda expressions:
getLine >>= (\x-> getLine) >>= (\y-> return [x, y])
The second line is errorneous because x
is not in scope when used in the return
, and I am happy with this. What concerns me this that in the first line the scope of x
appears to have 'leaked' out.
Is this 'leaking' considered bad practice? I am confused as to how it has remained in scope and not been lost immediately after the \x -> getLine
expression.