Your "gsi> " is buffered because there's no newline at the end.  To flush
the buffer and force it to be printed immediately, use 'hFlush' from the
System.IO library, or use 'hSetBuffering' from that same library:
http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html

I believe you can observe the same behavior in C.

- Phil


On Feb 8, 2008 4:14 PM, Jonathan Cast <[EMAIL PROTECTED]> wrote:

> $ cat > foo.c
> #include <stdio.h>
>
> int
> main()
> {
>   char s[1024];
>   printf("gsi> ");
>   gets(s);
>   printf("%s\n", s);
>   return 0;
> }
> $ make foo
> cc     gsi.c   -o gsi
> $ ./foo
> warning: this program uses gets(), which is unsafe.
> gsi> hello
> hello
> $ cat > foo.hs
> main = do
>   putStr "gsi> "
>   s <- getLine
>   putStrLn s
> $ ghc foo.hs -o foo
> $ ./foo
> hello
> gsi> hello
>
> (This is on MacOS X).  It strikes me that GHC is being
> extraordinarily unhelpful here.  Is there anyone on the planet who
> ever actually wants this behavior?
>
> jcc
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to