[Haskell-cafe] hPutStrLn and hFlush

Donn Cave donn at drizzle.com
Mon Jan 9 12:19:35 EST 2006


On Mon, 9 Jan 2006, Stepan Golosunov wrote:
> On Mon, Jan 09, 2006 at 04:57:51PM +0100, Gracjan Polak wrote:
...
>> So the output is truncated. When I uncomment hFlush, file is fully written.
>> Is this expected/documented behaviour?
> 
> This is the usual behavior when file is not closed. And example from
> http://www.haskell.org/onlinereport/io.html suggests that using hClose
> is necessary.

I guess it may be the usual behavior for ghc, since it works the
same for me on MacOS X.

In other languages with similar buffered output, finalizers deal with
this automatically on exit, and explicit flush or close is needed only
in relatively rare circumstances.  C, for example ... in fact, I'm
surprised to see this behavior in any I/O library.  The point of difference
I expect, in more modern languages, is between immediate and deferred
finalization.

	Donn Cave, donn at drizzle.com



More information about the Haskell-Cafe mailing list