Re: Lazy streams and unsafeInterleaveIO (another 'safe' solution offered)

2003-01-01 Thread Richard E . Adams
On Sunday, December 22, 2002, at 04:00 AM, Jyrinx wrote: As an experiment for a bigger project, I cooked up a simple program: It asks for integers interactively, and after each input, it spits out the running total. The wrinkle is that the function for calculating the total should be a

Re: Lazy streams and unsafeInterleaveIO

2002-12-25 Thread Glynn Clements
Jyrinx wrote: [...] and the inability to handle exceptions (the actual exception won't occur until after e.g. getContents has returned). But how does this differ from strict I/O? I mean, say there's a disk error in the middle of some big file I want to crunch. Under traditional I/O,

Re: Lazy streams and unsafeInterleaveIO

2002-12-25 Thread Jyrinx
Glynn Clements wrote: Jyrinx wrote: [...] and the inability to handle exceptions (the actual exception won't occur until after e.g. getContents has returned). But how does this differ from strict I/O? I mean, say there's a disk error in the middle of some big file I want to crunch.

Re: Lazy streams and unsafeInterleaveIO

2002-12-24 Thread Remi Turk
On Mon, Dec 23, 2002 at 09:05:00AM +, Glynn Clements wrote: Jyrinx wrote: So is this lazy-stream-via-unsafeInterleaveIO not so nasty, then, so long as a few precautions (not reading too far into the stream, accounting for buffering, etc.) are taken? I like the idiom Hudak uses

Re: Lazy streams and unsafeInterleaveIO

2002-12-24 Thread William Lee Irwin III
On Mon, Dec 23, 2002 at 09:05:00AM +, Glynn Clements wrote: The main problems with lazy I/O are the lack of control over ordering (e.g. you can't delete the file until a stream has been closed, but you may not be able to control how long the stream remains open), and the inability to

Re: Lazy streams and unsafeInterleaveIO

2002-12-23 Thread Glynn Clements
Jyrinx wrote: So is this lazy-stream-via-unsafeInterleaveIO not so nasty, then, so long as a few precautions (not reading too far into the stream, accounting for buffering, etc.) are taken? I like the idiom Hudak uses (passing a stream of I/O results to the purely functional part of the

Lazy streams and unsafeInterleaveIO

2002-12-22 Thread Jyrinx
As an experiment for a bigger project, I cooked up a simple program: It asks for integers interactively, and after each input, it spits out the running total. The wrinkle is that the function for calculating the total should be a non-monadic stream function (that is, type [Integer] - [Integer]

Re: Lazy streams and unsafeInterleaveIO

2002-12-22 Thread Remi Turk
On Sun, Dec 22, 2002 at 04:00:45AM -0800, Jyrinx wrote: As an experiment for a bigger project, I cooked up a simple program: It asks for integers interactively, and after each input, it spits out the running total. The wrinkle is that the function for calculating the total should be a

Re: Lazy streams and unsafeInterleaveIO

2002-12-22 Thread Jyrinx
Remi Turk wrote: On Sun, Dec 22, 2002 at 04:00:45AM -0800, Jyrinx wrote: As an experiment for a bigger project, I cooked up a simple program: It asks for integers interactively, and after each input, it spits out the running total. The wrinkle is that the function for calculating the total

Re: Lazy streams and unsafeInterleaveIO

2002-12-22 Thread Hal Daume III
BTW, I already found a major problem with the code I attached earlier, using unsafeInterleaveIO: Run in GHCi (as I had done), it works fine; but compiled by GHC and run as an executable, it waits for input and *then* displays the prompt after the user hits Enter ... not very helpful. I

Re: Lazy streams and unsafeInterleaveIO

2002-12-22 Thread Jyrinx
Hal Daume III wrote: BTW, I already found a major problem with the code I attached earlier, using unsafeInterleaveIO: Run in GHCi (as I had done), it works fine; but compiled by GHC and run as an executable, it waits for input and *then* displays the prompt after the user hits Enter ... not