read package:streaming

Make a stream of strings into a stream of parsed values, skipping bad cases
>>> S.sum_ $ S.read $ S.takeWhile (/= "total") S.stdinLn :: IO Int
1000<Enter>
2000<Enter>
total<Enter>
3000
Read the lines of a file, using a function of the type: 'Stream (Of String) IO () -> IO a' to turn the stream into a value of type 'IO a'.
>>> S.writeFile "lines.txt" $ S.take 2 S.stdinLn
hello<Enter>
world<Enter>

>>> S.readFile "lines.txt" S.print
"hello"
"world"
Read values from stdin, ignoring failed parses.
>>> :set -XTypeApplications

>>> S.sum $ S.take 2 (S.readLn @IO @Int)
10<Enter>
12<Enter>
22 :> ()
>>> S.toList $ S.take 2 (S.readLn @IO @Int)
10<Enter>
1@#$%^&*\<Enter>
12<Enter>
[10,12] :> ()
Read an IORef (Maybe a) or a similar device until it reads Nothing. reread provides convenient exit from the io-streams library
reread readIORef    :: IORef (Maybe a) -> Stream (Of a) IO ()
reread Streams.read :: System.IO.Streams.InputStream a -> Stream (Of a) IO ()