I have the following relatively simple concurrent haskell program:

import IO
import Concurrent

main = 
        let 
        loop ch = hPutChar stdout ch >> loop ch
        in
        forkIO (loop 'a') >> (let booga = (do
                                        out <- hGetLine stdin
                                        hPutStrLn stdout out
                                        booga)
                                in
                                booga)

Now, the expected results of this would be that it would print out a lot
of 'a' characters and if you happened to type something else in, it would
echo that as well somewhere in the midst.  HOWEVER, it seems with ghc 4.02
either this is not the case (and concurrent haskell is basically useless)
or I'm doing something horribly wrong.  Here's what happens when I run the
above code:

$ ./loopa
aeunt
aeunt
hello
hello
?
?
it
it

is anyone home?
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaais anyone home?
grrrr
grrrr
^C
$

As you can see, the input/echo process seems to be the only one running
initially, then the 'a' printing loop wakes up just long enough to spit
out a chunk of characters before going back to sleep.  So, as far as I can
tell, there is no way to have a blocked listening process lurking in the
background on a stream, because that blocking will halt all other
processing in the haskell program!  What's wrong here?

           ------------------ Peter Amstutz --------------------
           -------------- [EMAIL PROTECTED] -------------
           ------- http://www-unix.oit.umass.edu/~tetron -------
           -----------------------------------------------------

Reply via email to