[Haskell-cafe] Trapping getChar before echo

Mark Spezzano mark.spezzano at chariot.net.au
Mon Feb 1 03:45:22 EST 2010

I've tried this example and it just lets me type in anything in CAPITALS, which is nice, but Delete key doesn't delete and the arrow keys unfortunately let me manoeuvre the cursor all over the screen. Also the biggest problem is that Enter doesn't terminate the input session.

Isn't there a simple way to do something like this?

Surely Haskell must have a standard getLine function that support CAPITALS and backspacing and no arrow keys. Arrows keys with history would be nice.


On 31/01/2010, at 11:27 PM, Andrew Coppin wrote:

> 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?
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list