Hey Madhu,

Right, this is another gotcha -- haskell has a bunch of them.

As Tristan and Brandon have remarked, the runhaskell interpreter and compiled programs handle output buffering differently.

Here are changes to make your game work:

On Wed, Feb 4, 2015 at 10:23 AM, Madhu Babu <madhub.bits@gmail.com> wrote:
import System.Random
import Control.Monad(when)
import System.IO
 
main = do
  ranGen <- getStdGen
  let (rand,_) = randomR (1,10) ranGen :: (Int,StdGen)
  hSetBuffering stdout NoBuffering
 
  putStr "Guess a number between 1 and 10 : "

You might want to take a look at the "Summing Two Numbers" section here:

https://www.haskell.org/onlinereport/io.html

-- Kim-Ee