Quoth brian <[EMAIL PROTECTED]>:
| On Fri, Aug 29, 2008 at 11:15 AM, Donn Cave <[EMAIL PROTECTED]> wrote:
|> Quoth brian <[EMAIL PROTECTED]>:
|>
|> | I want to use Parsec to parse NNTP data coming to me from a handle I
|> | get from connectTo.
|>
|> I would implement the network service
|> input data stream myself, with timeouts
|
| Could you explain a little about how this would look?
|
| If it's reading characters trying to make a String we want to call a
| 'line', isn't that what the parser is supposed to be doing? If you
| were parsing /etc/passwd, would you read each line yourself and give
| each one to Parsec?

You bet, given that passwd is a simple line record file and I'm reasonably
confident that hGetLine will do what I want for a disk file (or more or
less so, anyway, since while I don't want end of file to raise an exception,
I'm aware of work-arounds for this.)  On the other hand, for the very same
reason, I wouldn't worry too much about letting a parse function read the
data -- from a disk file.

With a network client, though, the value of those buffered I/O routines
isn't so obvious to me.  While it can be a convenient metaphor in some
common circumstances, a socket is not a file and the notion easily becomes
more trouble than it's worth.

I wouldn't read byte-by-byte, but rather read available data into my own
buffer.

        Donn Cave, [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to