Now let's use the substitution rules to show why these two are equivalent.

main = 
  do
    x <- getLine
    do x<- getLine
       putStrLn x
    putStrLn x

and

main =
   getLine >>=
     (\x-> 
        (getLine >>= putStrLn) 
        >> putStrLn x 
     )

We begin with the first form and apply the substitution rules to convert to the second.