Unsafe hGetContents

Duncan Coutts duncan.coutts at googlemail.com
Tue Oct 20 11:39:40 EDT 2009

On Tue, 2009-10-20 at 15:45 +0100, Simon Marlow wrote:

> > I've not yet seen anyone put forward any practical programs that have
> > confusing behaviour but were not written deliberately to be as wacky as
> > possible and avoid all the safety mechanism.
> >
> > The standard use case for hGetContents is reading a read-only file, or
> > stdin where it really does not matter when the read actions occur with
> > respect to other IO actions. You could do it in parallel rather than
> > on-demand and it'd still be ok.
> >
> > There's the beginner mistake where people don't notice that they're not
> > actually demanding anything before closing the file, that's nothing new
> > of course.
> If the parallel runtime reads files eagerly, that might hide a resource 
> problem that would occur when the program is run on a sequential system, 
> for example.

That's true, but we have the same problem without doing any IO. There
are many ways of generating large amounts of data.


More information about the Haskell-prime mailing list