Incomplete output when hPutStr is lifted

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Thu Nov 27 23:41:14 EST 2003


On Thu, Nov 27, 2003 at 04:09:00PM -0300, andrew cooke wrote:
> 
> Hi,
> 
> If I compile and run the code below, the file "foo" contains 10 lines
> of output (as I would expect), but the file "bar" contains just 9 -
> the final line is missing.  If I add a "join", as in the comment, then
> all 10 lines appear.
> 
> I don't understand why, completely - my best guess is that it's
> related laziness and the final result of the fold not being used.

No, it's not about laziness. The last result (action of type IO Int) is
not threaded through the IO monad (forgive me the clumsy wording).

> However, in that case, I'm worried that the "join fix" isn't
> guaranteed to work.

Join will work, but why are you using such a strange code anyway ?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links


More information about the Haskell mailing list