[Haskell-cafe] System.Timeout problems
Ian Lynagh
igloo at earth.li
Sun May 27 11:05:06 EDT 2007
On Sun, May 27, 2007 at 01:32:40AM +0100, Neil Mitchell wrote:
>
> Sadly, it doesn't seem to work for me. Here are the tests I've been
> using, the results I get, and what I would have liked. All are GHC 6.6
> on Windows.
>
> -- TEST 1
> import System.TimeoutGHC
>
> main :: IO ()
> main = do
> r <- timeout (5 * 10^6) (putStrLn "here")
> print r
>
> Without -threaded:
> here >> Just () >> wait 5 seconds
>
> Without -threaded:
> here >> wait 5 seconds >> Just ()
>
> So, either way, I get a 5 second delay - not something I want.
Works for me with 6.6.1 on Windows and Linux, e.g. on Windows:
$ ghc --make -threaded q.hs -o q
[1 of 2] Compiling TimeoutGHC ( TimeoutGHC.hs, TimeoutGHC.o )
[2 of 2] Compiling Main ( q.hs, q.o )
Linking q.exe ...
$ time ./q
here
Just ()
real 0m0.070s
user 0m0.010s
sys 0m0.010s
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6.1
> -- TEST 2
> import System.TimeoutGHC
>
> main :: IO ()
> main = do
> r <- timeout (length [1..]) (putStrLn "here")
> print r
>
> Now, with either -threaded, or without, it never terminates.
This is expected, as it looks at n before doing anything. I'm not sure
why it does so though; it would be nice if timeout just acted as if n
was positive and left other cases to the caller.
Thanks
Ian
More information about the Haskell-Cafe
mailing list