[Haskell-cafe] Windows, or GHC?

Svein Ove Aas svein.ove at aas.no
Tue Feb 12 14:11:24 EST 2008

2008/2/12 Magnus Therning <magnus at therning.org>:
> The following code will on Linux print three strings each followed by a NULL
> byte:
> module Main where
> putStr0 = putStr $ s ++ "\0"
> main = do
>     putStr0 "Hello"
>     putStr0 "Hello"
>      putStr0 "Hello"
> On Windows however it will print nothing!  In order to trigger printing I
> have to change the definition of putStr0 to
> putStr0 = putStr (s ++ "\0") >> hFlush stdout
> Is this difference in behaviour due to a bug in GHC on Windows or just a
> quirkiness of the platform?
I can't directly answer, but a way to find out would be to try the
same thing in C.

It seems to me that, while Linux implicitly flushes streams on exit,
Windows is failing to do so. So try the same output in C, with and
without fflush, and.. you'll see.

A program to do this follows for your convenience.

#include <stdio.h>

int main() {
  int i;
  for (int i=0; i<3; i++)
  return 0;

More information about the Haskell-Cafe mailing list