btw, why don't you use 'putStrLn' instead? I.e.
putStrLn "Enter query:"
I think isEOF just blocks waiting for the input, and when user gives
an input it is consumed by getLine.
Maybe it's more appropriate to use try or catch to handle getLine
failure?
What exactly does it mean for isEOF to "block" waiting for input? It's
a single threaded program, so I thought isEOF just checks a flag or a
bit somewhere and then the rest of the IO monad gets executed. So it's
still not clear to me why stuff isn't getting flushed to stdout.
On Nov 18, 6:44 pm, Alex M <amord...@gmail.com> wrote:
> On Thu, Nov 17, 2011 at 2:36 AM, Eugene Perederey
>
Stdin is a stream, talking about EOF is a little strange at times. Try
this, run your program and type CTRL-D. Your program will run taking
the true case. Given stdin is a stream the question of 'are we are the
eof?' can't be answered until the user types in some input. Maybe they
type 'c' and we can say no its not the eof, maybe they type CTRL-D and
we say yes it is the end of file.
If you want to do a lot of user interaction then perhaps using the
Haskel version of readline would be the best approach:
http://hackage.haskell.org/package/haskeline-0.6.4.5
Cheers,
David
What exactly is the question?
hIsEOF returns True if you are at EOF. To do that, it may have to
wait for more input. For example, if your handle is attached to a TCP
socket and there is no data buffered, then hIsEOF will block until the
TCP stack receives either a data segment or a FIN segment. The
behavior for pipes Unix domain sockets, and terminals is similar--it
will block until the other end of the connection has done something to
distinguish an EOF condition from a non-EOF condition.
David