[Haskell-beginners] Read just one word from input

Brandon Allbery allbery.b at gmail.com
Sun Feb 26 22:58:44 CET 2012

On Sun, Feb 26, 2012 at 13:05, Alexander Batischev <eual.jp at gmail.com>wrote:

> The main idea behind that is if user entered more values then required,
> they won't be lost but instead consumed by subsequent reads (calls to
> getWord). That's how scanf() in C and 'cin >>' in C++ behave, and I'm
> quite surprised that I can't do that in Haskell.

Almost every time I have used non-line-oriented I/O in a basic terminal I/O
context, I have had to go back and rewrite it to be line-oriented.  It's
too easy to get yourself into odd issues where the tty line buffer and your
program's notion of said buffer don't agree (if the terminal is in "icanon"
mode) or discover you need backspace to work (if not).

If you absolutely insist on shooting yourself in the foot this way in
Haskell, it can be done; but there is no reason Haskell should make it
*easy* to do so.  That's C's superpower.  :)

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120226/92b81cc2/attachment.htm>

More information about the Beginners mailing list