
7 Jun
2011
7 Jun
'11
8:54 a.m.
On 04:30 Tue 07 Jun , Christopher Howard wrote:
In a reply to an earlier question, someone told me that "do" expressions are simply syntactic sugar that expand to expressions with the >> and
= operators. I was trying to understand this (and the Monad class) better.
I see in my own experiments that this...
main = do ln1 <- getLine putStrLn ln1
translates to this:
main = getLine >>= \ln1 -> putStrLn ln1
However, what does this translate to?:
main = do ln1 <- getLine ln2 <- getLine putStrLn (ln1 ++ ln2)
It translates to: main = getLine >>= \ln1 -> getLine >>= \ln2 -> putStrLn (ln1 ++ ln2) -- Mats Rauhala MasseR