[Haskell-cafe] getContents and lazy evaluation

Robert Dockins robdockins at fastmail.fm
Fri Sep 1 18:30:29 EDT 2006

On Friday 01 September 2006 18:01, Donn Cave wrote:
> On Fri, 1 Sep 2006, Robert Dockins wrote:
> > On Friday 01 September 2006 16:46, Duncan Coutts wrote:
> ...
> >> Note also, that with lazy IO we can write really short programs that are
> >> blindingly quick. Lazy IO allows us to save a copy through the Handle
> >> buffer.
> (Never understood why some people think it would be such a good thing
> to be blinded, but as long as it's you and not me ... )
> >> BTW in the above case the "bad thing that will happen" is that contents
> >> will be truncated. As I said, I think it's better to throw an exception,
> >> which is what Data.ByteString.Lazy.hGetContents does.
> >
> > Well, AFAIK, the behavior is officially undefined, which is my real beef.
> >  I agree that it _should_ throw an exception.
> Is this about Microsoft Windows?  On UNIX, I would expect deletion of
> a file to have no effect on I/O of any kind on that file.  I thought
> the problems with hGetContents more commonly involve operations on
> the file handle, e.g., hClose.

Ahh... I think you're right.

However, this just illustrates the problem.  The point is that the answer the 
question "what happens when I do <odd thing involving lazy I/O>" is "it 
depends".  And to the obvious followup question "what does it depend on?" the 
answer is "well.... it's complicated".

> 	Donn Cave, donn at drizzle.com

Rob Dockins

Talk softly and drive a Sherman tank.
Laugh hard, it's a long way to the bank.
       -- TMBG

More information about the Haskell-Cafe mailing list