Re: Re[2]: [Haskell-cafe] `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-05 Thread Scott Bell
Bulat, yes, with both variants. actually, second one should be easier to implement and understand. you should look into unsafeInterleaveIO section of http://haskell.org/haskellwiki/IO_inside This seems to do what I want, and unless I'm overlooking something it feels very straight-forward:

Re: [Haskell-cafe] `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-04 Thread Scott Bell
Bulat, 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

Re[2]: [Haskell-cafe] `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-04 Thread Bulat Ziganshin
Hello Scott, Wednesday, April 4, 2007, 6:39:22 PM, you wrote: vGetChar (StreamWithTimeout s t) = do timeout t (vGetChar s) (error Timed out!) If possible, I would like to try and use lazy [Char]s -- this would greatly simplify my usage of the Parsec parser. or, even

[Haskell-cafe] `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-03 Thread Scott Bell
Hello all, I'm writing an application to interact with other applications remotely though TCP sockets (primarily), and in the future with local apps also. So far I have a Parsec parser to match the input that I want to see, which works if the remote connection is particularly speedy - but the

Re: [Haskell-cafe] `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-03 Thread Bulat Ziganshin
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