Hello Scott,

Wednesday, April 4, 2007, 1:54:27 AM, you wrote:

> Match the Parsec parser against the input as soon as a match
> is available, but fail if the match is unavailable after a timeout
> value if no further data is available on the socket.

one possible solution: use Streams library and establish a stream
transformer that adds an error call on timeout. something like this:

data StreamWithTimeout s = StreamWithTimeout s Timeout

instance Stream s => Stream (StreamWithTimeout s) where
  vGetChar (StreamWithTimeout s t) = do
     timeout t (vGetChar s)
               (error "Timed out!")

then you can use standard vGetContents lazy string reading in order to
get expected behaviour

or, even simple, you can make your own variant of hGetContents which
adds a timeout checks before each next call to hGetChar or hGetBuf

-- 
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to