module System.IO.NoBufferingWorkaround (
initGetCharNoBuffering, getCharNoBuffering
) where
#if defined(__GLASGOW_HASKELL__) && defined(mingw32_HOST_OS)
import Data.Char(chr)
import Foreign.C.Types(CInt(..))
foreign import ccall unsafe "conio.h getch"
c_getch :: IO CInt
initGetCharNoBuffering = return ()
getCharNoBuffering = fmap (chr . fromEnum) c_getch
#else
import System.IO(hSetBuffering, BufferMode(NoBuffering), stdin)
initGetCharNoBuffering = hSetBuffering stdin NoBuffering
getCharNoBuffering = getChar
#endif
initGetCharNoBuffering :: IO ()
getCharNoBuffering :: IO Char