H98 Report: input functions

Glynn Clements glynn.clements@virgin.net
Mon, 9 Sep 2002 17:02:20 +0100


Simon Peyton-Jones wrote:

> | In 7.1, the Report says of getChar, getContents and friends:
> | 
> | 	"By default, these input functions echo to standard output."
> | 
> | This would mean that the example given:
> | 
> | 	main = interact (filter isAscii)
> | 
> | would print the input with all ASCII characters duplicated.
> | 
> | Surely it should say that if the standard input is a terminal device the
> | input is echoed on that device.  Or maybe the sentence should be deleted.
> 
> Ross's speaks truth.  In fact, the overall behaviour of a Haskell
> program when used from a terminal ought to be predicable regardless of
> OS.  And indeed one expects the behaviour to differ depending on whether
> stdin is a terminal or a file.
> 
> So I propose to adopt Ross's modification: "Surely it should say that if
> the standard input is a terminal device the input is echoed on that
> device."  This describes what Haskell implementations actually do, and
> it describes the desired behaviour.
> 
> All this is about the Language Report.  In the Library Report, it says
> that "getLine" is sort for "hGetLine stdin".  So that implies that 
> 
> 	If the standard input (stdin) is a terminal device, 
> 	any input on stdin is echoed on that device
> 
> So, for consistency, I propose to add that to the IO chapter of the
> library report.
> 
> Does that seem right?

No. A terminal device may echo or it may not. Even if the run-time
explicitly enables echoing, there is no guarantee that it won't
subsequently be disabled.

Certainly, the existing statement is wrong, though.

-- 
Glynn Clements <glynn.clements@virgin.net>