[Haskell-cafe] Re: Strange console IO behavior (at least on Windows)
Tim Attwood
timothyea at comcast.net
Sat Aug 22 23:28:58 EDT 2009
Yeah, it's broken in windows. Here's the workaround
courtesy of Alistar Bayley. (ticket 2189)
{-# LANGUAGE ForeignFunctionInterface #-}
import Data.Char
import Control.Monad (liftM, forever)
import Foreign.C.Types
getHiddenChar = liftM (chr.fromEnum) c_getch
foreign import ccall unsafe "conio.h getch"
c_getch :: IO CInt
main = do
forever $ do
c <- getHiddenChar
putStrLn $ show (fromEnum c)
More information about the Haskell-Cafe
mailing list