[Haskell-cafe] Trapping getChar before echo

Andrew Coppin andrewcoppin at btinternet.com
Sun Jan 31 07:57:44 EST 2010

Michael Hartl wrote:
> import System.IO
> import Data.Char
> main = do
>   hSetEcho stdin False
>   hSetBuffering stdin NoBuffering
>   hSetBuffering stdout NoBuffering
>   scanLine
>       where scanLine = do 
>               c <- hGetChar stdin
>               putChar . toUpper $ c
>               scanLine

Last time I tried something like this [on Windows], it didn't seem to 
work. I wanted to trap arrow keys and so forth, but they seem to be 
being used for input history. (I.e., pressing the up-arrow produces 
previously-entered lines of text, and none of this appears to be 
reaching the Haskell program itself.) Has this changed since I tried it 
last year?

More information about the Haskell-Cafe mailing list