Re: [Haskell-cafe] Parsec and network data

2008-08-30 Thread Thomas Schilling
There's a whole bunch of other problems with lazy network IO. The big problem is that you cannot detect when your stream ends since that will happen inside unsafeInterleaveIO which is invisible from inside pure code. You also have no guarantee that the lazy code actually consumes code enough.

Re: [Haskell-cafe] Parsec and network data

2008-08-30 Thread Johan Tibell
On Sat, Aug 30, 2008 at 3:51 AM, Thomas Schilling [EMAIL PROTECTED] wrote: I remember Johan Tibell (CC'd) working on an extended variant of Parsec that can deal with this chunked processing. The idea is to teach Parsec about a partial input and have it return a function to process the rest (a

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread Donn Cave
Quoth brian [EMAIL PROTECTED]: | I want to use Parsec to parse NNTP data coming to me from a handle I | get from connectTo. Are you still having trouble with this? Take my opinion for what it's worth - I'm no Haskell guru - but for me, your basic approach is unsound. I would implement the

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread Johannes Waldmann
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

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread Derek Elkins
On Fri, 2008-08-29 at 20:01 +0200, Johannes Waldmann wrote: 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

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread brian
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

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread Donn Cave
Quoth Johannes Waldmann [EMAIL PROTECTED]: ... | 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

Re: [Haskell-cafe] Parsec and network data

2008-08-29 Thread Donn Cave
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

Re: [Haskell-cafe] Parsec and network data

2008-08-27 Thread Ketil Malde
Jeremy Shaw [EMAIL PROTECTED] writes: I probably shouldn't post when I don't quite understand the question, and I'm unsure whether this is about timeouts, lazy parsing of responses, or line endings? These seem like independent issues to me. Anyway: Polyparse has some lazy parsers: but Tomasz

Re: [Haskell-cafe] Parsec and network data

2008-08-27 Thread Ryan Ingram
On Tue, Aug 26, 2008 at 1:35 PM, brian [EMAIL PROTECTED] wrote: One unworkable approach I tried is to get a lazy String from the handle with hGetContents. [...] The OP had the same problem I did, so he made a variant of hGetContents with timeout support. The problem: he used something from

[Haskell-cafe] Parsec and network data

2008-08-26 Thread brian
Hi, I've been struggling with this problem for days and I'm dying. Please help. I want to use Parsec to parse NNTP data coming to me from a handle I get from connectTo. One unworkable approach I tried is to get a lazy String from the handle with hGetContents. The problem: suppose the first

Re: [Haskell-cafe] Parsec and network data

2008-08-26 Thread John Van Enk
Are you doing this all in a single thread? On Tue, Aug 26, 2008 at 4:35 PM, brian [EMAIL PROTECTED] wrote: Hi, I've been struggling with this problem for days and I'm dying. Please help. I want to use Parsec to parse NNTP data coming to me from a handle I get from connectTo. One

Re: [Haskell-cafe] Parsec and network data

2008-08-26 Thread brian
On Tue, Aug 26, 2008 at 3:38 PM, John Van Enk [EMAIL PROTECTED] wrote: Are you doing this all in a single thread? Yes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Parsec and network data

2008-08-26 Thread John Van Enk
Perhaps you'll want to continue with the hGetLine setup in one thread (assuming the NNTP data is line delimited), then in another, parse the data, then in a third, respond. Lookup how to use MVar's. Allowing the threads to block on reads/writes is a lot easier (logically) than figuring out the

Re: [Haskell-cafe] Parsec and network data

2008-08-26 Thread Jeremy Shaw
Hello, Polyparse has some lazy parsers: http://www.cs.york.ac.uk/fp/polyparse/ Perhaps that would do the trick? j. At Tue, 26 Aug 2008 15:35:28 -0500, brian wrote: Hi, I've been struggling with this problem for days and I'm dying. Please help. I want to use Parsec to parse NNTP data

Re: [Haskell-cafe] Parsec and network data

2008-08-26 Thread brian
On Tue, Aug 26, 2008 at 3:43 PM, John Van Enk [EMAIL PROTECTED] wrote: Perhaps you'll want to continue with the hGetLine setup in one thread (assuming the NNTP data is line delimited), then in another, parse the data, then in a third, respond. Sorry if my writing was unclear. I think hGetLine