[Haskell-cafe] getChar (NoBuffering) not working on Windows

Francesco Ariis fa-ml at ariis.it
Tue Jul 18 18:29:27 UTC 2017

Hello list,

    I am writing a small console application.

Today I was bitten by #2189 [1] ("hSetBuffering stdin NoBuffering doesn't
work on Windows"). To reproduce:

    import System.IO

    main :: IO ()
    main = hSetBuffering stdin NoBuffering >>
           getChar >>= putChar

    -- on linux you just need to press, say, 'c', on Win you
    -- need to press <Enter> too.

Is there any sensible (cross-platform) way of working around this?

[1] https://ghc.haskell.org/trac/ghc/ticket/2189

More information about the Haskell-Cafe mailing list