
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.