[Haskell-cafe] Parsec and network data

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Fri Aug 29 14:01:01 EDT 2008

Donn Cave wrote:

> ...  I would implement the network service
> input data stream myself, with timeouts, encryption, whatever as required,
> and then apply the parser to available data as a simple, pure function
> that returns NNTP results and whatever data remains.  So the parser would
> never see any streams or handles or anything, it would just get strings
> to parse.

A likely problem with that is that your implementation  of the "input
data stream" will still need to parse some information from it.
So you're going to replicate code from the parser.

I think the following is analoguous.

Imagine you're writing a parser for a simple programming language.
A program is a sequence of statements.
Fine, you do "readFile" (once) and then apply a pure Parsec parser.

Then you decide to include "import" statements in your  language.
Suddenly the parser needs to do IO. Assume the import statements
need not be the first statements  of the program
(there may be headers, comments etc. before).
Then you really have to interweave the parsing and the IO.

If anyone has a nice solution to this, please tell. - J.W.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080829/c12db864/signature.bin

More information about the Haskell-Cafe mailing list