Help on handles

Yeo Gek Hui yeogekhu@comp.nus.edu.sg
Tue, 11 Mar 2003 01:17:06 +0800 (GMT-8)


Hi,
Has anyone have experience reading from a handle using hGetContents when
the handle is still open and receives input from outside?
I need to do some manipulation to the contents and I can't afford to close
this handle. for example, an infinite stream "abcabc..." is written from
outside to this handle and I know that 'c' means the termination and I
want to get "abc", "abc" and the rest coming. I have used no-buffering for
my handle and have written a function,extractC to extract the string end  
with the terminating character c. There is one more function, keepRest
to keep the remainder of the stream. However, let's say response <-
hGetContents handle and the response still has "abcabc...". I know in
imperative language, response can be reassigned globally. How can I do
that in Haskell? This is because I want to avoid duplications and ensure
the program terminates.
Thanks a lot.
Cheers,
Gek                   ,-.___,-.
                      \> , , </
                      (   Y   )
                      .->-._.-<-
                    / /       \ \
                  ,' (         ) `.
                 (_,' )--._.--( `._)
                   ,-'   / \   `-.
                   (,-. ,'   `.,-. )