main = randomRIO (1,100) >>= guess 1
where
guess n x = putStrLn "Guess: " >> getLine >>= correct n x
correct n x y
| x == (read y :: Int) = putStrLn ("Correct!\n" ++ show n ++ " Guesses.") >> getLine >> return ()
| x > (read y :: Int) = putStrLn "Higher!\n" >> guess (n + 1) x
| x < (read y :: Int) = putStrLn "Lower!\n" >> guess (n + 1) x\n" ++ show n ++ " Guesses.") >> getLine >> return ()
| x > (read y :: Int) = putStrLn "Higher!\n" >> guess (n + 1) x
| x < (read y :: Int) = putStrLn "Lower!\n" >> guess (n + 1) x