
13 Oct
2007
13 Oct
'07
11:56 p.m.
Luke Palmer wrote:
Using this you can do more complex actions, like, for instance, adding two numbers:
readLine >>= (\x -> readLine >>= (\y -> print (x + y)))
Take a moment to grok that...
Which you might like to write:
do x <- readLine y <- readLine print (x + y)
you can leave out the parentheses and make it similarly readable, still without "do" (at least, readable once you get used to the style, which might look almost as weird as do-notation) readLine >>= \x -> readLine >>= \y -> print (x + y) Isaac