[Haskell-cafe] Unbuffered character IO under Windows XP?
Peter Schmitz
haskell.ps at gmail.com
Fri Dec 28 19:18:57 EST 2007
module Main(main) where
import System.IO
main = do
b1 <- hGetBuffering stdin
print b1
b2 <- hGetBuffering stdout
print b2
-- not sure if these help, or are needed
hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
b1 <- hGetBuffering stdin
print b1
b2 <- hGetBuffering stdout
print b2
putStr "0"
c <- getChar -- echoes during input by default
putStr "1" -- want this output w/o hitting Enter
hFlush stdout -- adding this does not help
putStrLn [c]
{------------------- Output:
E:\ghcTest>ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.1
E:\ghcTest>ghc --make main
[1 of 1] Compiling Main ( main.hs, main.o )
Linking main.exe ...
E:\ghcTest>main
LineBuffering
LineBuffering
NoBuffering
NoBuffering
0a
1a
E:\ghcTest>
----------------- Question:
Is it possible to have unbuffered character IO under
Windows XP?
I would like to be able to type a single character and have
the processing and IO continue without having to hit Enter.
I.e., rather than this
(had to hit Enter after typing the 'a' in '0a'):
0a
1a
I would like to have this
(without having to hit Enter after typing the char):
0a1a
I have tried a few combinations of hSetBuffering and
put/get Str/Char functions, without success.
NOTE:
I need to run under Windows XP, non-administrator account.
This test was run using the normal XP shell cmd.exe.
Thanks much in advance.
-- Peter
--------}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071228/83a94609/attachment.htm
More information about the Haskell-Cafe
mailing list