Hi, I'm trying to do IO and it isn't lazy enough.  My problem seems
similar to this one:  Write a function that lazily reads characters
from stdin, just like getContents does.  These two don't work:

    lazyRead :: IO String
    lazyRead = do first_char <- getChar
                  rest <- lazyRead
                  return $ first_char:rest

    lazyRead2 :: IO String
    lazyRead2 = (liftM2 (:)) getChar lazyRead2

because neither has the intended behavior, because if I type:

    lazyRead >>= putChar . head

Then it seems that all of stdin is read, not just the first character,
which is different from:

    getContents >>= putChar . head

which only reads one character.  So how do you write getContents in
haskell?  Thanks for any insight.


-- 
Ben Escoto

Attachment: pgp00000.pgp
Description: PGP signature

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to