[Haskell-beginners] Read just one word from input

Alexander Batischev eual.jp at gmail.com
Sun Feb 26 19:05:09 CET 2012


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120226/b0f7551e/attachment.pgp>


More information about the Beginners mailing list