hWaitForInput and timeouts

2004-10-03 Thread Peter Simons
Hi, I have another I/O problem. I need to time out when a Handle blocks forever. I am using hWaitForInput anyway, so that shouldn't be a problem, but the documentation says that using this feature will block all IO threads? Is it much work to fix this? I _could_ forkIO a racer thread myself, of co

Re: Bools are not unboxed

2004-10-03 Thread Tomasz Zielonka
On Sun, Oct 03, 2004 at 04:03:55PM +0200, Carsten Schultz wrote: > Hi Tomasz! Hi Carsten! > > To my surprise, it was much slower and made many allocations: > [... > > Then I noticed the cause: > > GHC.Prim.<# returns a boxed, heap allocated Bool, and so do other > > primitive comparison

Re: Bools are not unboxed

2004-10-03 Thread Carsten Schultz
Hi Tomasz! On Sun, Oct 03, 2004 at 03:07:01PM +0200, Tomasz Zielonka wrote: > Hello! > > I was playing with monadic looping a'la replicateM_ and I created this > function: > > for :: Int -> IO () -> IO () > for 0 _ = return () > for n x = x >> for (n - 1) x > > Compiled with -O2, it

Re: Bools are not unboxed

2004-10-03 Thread Tomasz Zielonka
On Sun, Oct 03, 2004 at 03:07:01PM +0200, Tomasz Zielonka wrote: > Then I noticed the cause: > GHC.Prim.<# returns a boxed, heap allocated Bool, and so do other > primitive comparison operators. > > Would it be difficult to add Bool unboxing to GHC? > Maybe it would suffice to use preallo

Bools are not unboxed

2004-10-03 Thread Tomasz Zielonka
Hello! I was playing with monadic looping a'la replicateM_ and I created this function: for :: Int -> IO () -> IO () for 0 _ = return () for n x = x >> for (n - 1) x Compiled with -O2, it is really fast and makes no unnecessary allocations. Tested with this main main = for 1