Re: How do I sleep in Ghc?

2003-12-08 Thread Bernard James POPE
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.
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: How do I sleep in Ghc?

2003-12-08 Thread Lyle Kopnicky





  
  
  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.
  



[EMAIL PROTECTED] 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
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
  



___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: How do I sleep in Ghc?

2003-12-08 Thread Mike Gunter

Control.Concurrent.threadDelay
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: How do I sleep in Ghc?

2003-12-08 Thread Ken Shan
[EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] 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

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell