[Haskell-cafe] Character I/O

Andrew Coppin andrewcoppin at btinternet.com
Tue Mar 31 15:38:12 EDT 2009

I ran the following program:

 >module Main where
 >main = do
 >  putStrLn "Key"
 >  c <- getChar
 >  print c
 >  main

Unfortunately, it doesn't do what I was hoping. Specifically, it only 
returns any data when I hit [return]. It also seems to be giving me a 
command history somehow. Special keys (e.g., arrow keys, backspace, 
escape) don't get through to the application.

I'm trying to write a program that uses individual keys as commands. 
What's the correct way to get this to work?

More information about the Haskell-Cafe mailing list