lazy Printing question

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Mon, 21 Jul 2003 14:51:09 +0100


> If I try to run the program (compiled using GHC 6), it calculates all
> members of the list and then prints the whole list in the end. Since
> Haskell is 'lazy' I was expecting behaviour similar to HUGS where it prints
> the numbers as it finds them. Does this behaviour have something to do with
> the monadic IO in Haskell? I am a Haskell newbie and can't even claim
> having understood the "gentle introduction" properly.

My guess would be that you're seeing buffering behaviour where GHC fills up a 
buffer of characters for output and flushes it every 1000, 4000 or whatever 
characters.

IIRC correctly, buffering is off by default in Hugs but on by default in GHC.

You can turn this off with the Haskell 98 function hSetBuffering described in 
section 11.4.2 of the library report.

--
Alastair