echoing of getChar, getLine, getContents

Simon Marlow simonmar at microsoft.com
Mon Sep 22 14:58:16 EDT 2003


 
> The report states about getChar, getLine, and getContents:
> 
> "By default, these input functions echo to standard output."
> 
> In version 1.3 of the report, it used to continue
> "Functions in the I/O library provide full control over echoing." 
> 
> Apparently, this has been removed and the I/O library contains
> neither facilities to control echoing nor a specification of what the
> h-cousins hGetChar, hGetLine, and hGetContents are supposed to do wrt
> echoing. Can I rely on them not to echo their inputs?

Clearly the report is vague here, so I'll just comment on what GHC does.
By default, input from a terminal will echo.  The following functions
are provided by System.IO (GHC only, not Hugs or NHC), and control
terminal echoing:

  hSetEcho :: Handle -> Bool -> IO ()
  hGetEcho :: Handle -> IO Bool

Input from a non-terminal will not echo.  GHC's IO library never does
any actual echoing itself, it simply gives hints to the OS's terminal
API to turn echoing on or off.

Cheers,
	Simon



More information about the Haskell mailing list