[Haskell-beginners] Read just one word from input

Tim Perry tim.v2.0 at gmail.com
Sun Feb 26 21:31:06 CET 2012


Turn off buffering and call "words"

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

> Hello Haskellers,
> 
> Is there really no way to read input word-by-word? E.g., if user types
> 
>  1 2 3 4 5
> 
> function (let's call it getWord :: IO String) should first return "1",
> then "2", and so on.
> 
> 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.
> 
> -- 
> Regards,
> Alexander Batischev
> 
> 4096R/0C8BFD03
> CE6C 4307 9348 58E3 FD94  A00F 3569 61A2 0C8B FD03
> 
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list