Hi there, 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? Thanks. Ben. This message is intended only for the addressee and may contain information that is confidential or privileged. Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. If you have received this email in error, please delete and advise us immediately.
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.
Here's a POSIX implementation of a sleep function in C, as found in the book "Advanced Programming in the UNIX Environment": http://www.yendor.com/programming/unix/apue/lib.svr4/sleep.c AFAIK, all the GHC platforms, including Windows, are POSIX compliant. You could compile this code separately and call it via the FFI. If it doesn't work on Windows, you could instead call: Win32::Sleep(TIME) [CORE] Pauses for TIME milliseconds. The timeslices are made available to other processes and threads. Hope that helps, Lyle Kopnicky BTW, you have a very interesting disclaimer in your message. I hope I will not go to jail for reading it. Ben_Yu@asc.aon.com wrote:
Hi there,
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?
Thanks.
Ben.
This message is intended only for the addressee and may contain information that is confidential or privileged. Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. If you have received this email in error, please delete and advise us immediately.
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Ben_Yu@asc.aon.com wrote in article <OFBA77FED4.FBE4FC84-ON86256DF6.00802FA7-86256DF6.0080EF98@COMBINED.COM> in gmane.comp.lang.haskell.general:
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?
Use threadDelay from the Control.Concurrent package. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig International Human Rights Day * 2003-12-10 * http://www.un.org/rights/ What if All Chemists Went on Strike? (science fiction) http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html
participants (5)
-
Ben_Yu@asc.aon.com -
Bernard James POPE -
Ken Shan -
Lyle Kopnicky -
Mike Gunter