By using (>>=), we can use the result of first IO action in second IO action.
Prelude> :t (>>=)
(>>=) :: Monad m => m a -> (a -> m b) -> m b
square :: Integer -> Integer
square x = (x*x)
main = putStrLn "Enter a number"
>>= \x -> putStrLn ("Square of " ++ (show x) ++ " is " ++ show (square x))
$ ghc Sample.hs
[1 of 1] Compiling Main ( Sample.hs, Sample.o )
Linking Sample ...
Enter a number
Square of 10 is 100
All the statements in the do block are internally combined using >>, >>=.
putStrLn "'Enter a Number"
a <- readLn
Above code snippet is translated like below.