IO-System

Sigbjorn Finne sof@galois.com
Tue, 17 Sep 2002 06:30:27 -0700


 "Simon Marlow" <simonmar@microsoft.com> writes:
> > I'd settle for that kind of indiscriminate flushing -- as is,
> > trivial I/O examples such as
> >
> > main = do
> >    putStr "What is your name? "
> >    ls <- getLine
> >    putStrLn ("Hello " ++ ls ++ "!")
> >
> > fail to behave as expected.
>
> That depends on what you expect... :-)  The Haskell report says nothing
> about triggering a flush on stdout when reading from stdin.
>
...
> Suppose we were to implement this, when exactly should it be enabled?
> All the time?  When stdin is a terminal?  When stdin and stdout are both
> connected to the same terminal?  For every output handle connected to
> the same terminal as stdin?  Should it happen for a socket too?  (if
> not, won't that be confusing for users?)
>

The previous impl had facilities for controlling this - you could label
handles
as being connected (i.e., read() on one caused flushes on the other.) By
default, stdin was connected to stdout and stderr. If that turned out to
be troublesome, the connection could be broken (I could be mistaken,
but I believe the implementation of hConnectTo didn't provide this;
trivial to add.) My guess is that most of _your_ users wouldn't want to
modify that default. As a data point, I cannot remember this ever being
reported as a problem.

If you don't think this is solving a problem, fine. I've had my say.

--sigbjorn