You can safely bring him out of what you already know. Start with a full bracket in addOneInt':
addOneInt' = getLine >>= (\line ->
putStrLn (show (1 + read line :: Int)) )
Then you reverse2linescan be equivalently written as
reverse2lines =
do { line1 <- getLine ;
do { line2 <- getLine ;
do { putStrLn (reverse line2) ;
do { putStrLn (reverse line1) } } } }
Applying the one-step transformation that you have already used for addOneInt, as many times as necessary, you would get
reverse2lines' :: IO ()
reverse2lines' =
getLine >>= (\line1 ->
getLine >>= (\line2 ->
putStrLn (reverse line2) >>
putStrLn (reverse line1) ) )
- , , .
monad fail, , (line1, line2) , .