How do I sleep in Ghc?

Bernard James POPE bjpop at cs.mu.OZ.AU
Tue Dec 9 13:04:04 EST 2003


Ben writes:
> In Ghc, how do I sleep for say, 1 minute? I'm trying to write a simple file
> arrival listener and could not find the sleep api. Can haskell do it at
> all?

You can call system commands via System.system. On unix this ought to work.
I don't know if there is an equivalent to sleep on windows...

   module Main where

   import System (system)
   import IO

   main 
      = do hSetBuffering stdout NoBuffering
           hPutStrLn stdout "I'm about to sleep" 
           exitCode <- system "sleep 60"
           hPutStrLn stdout $ "slept with exit code: " ++ show exitCode

Cheers,
Bernie.


More information about the Haskell mailing list