[Haskell-cafe] Suggestions for a hReadUntilStr implementation

Matt Revelle mrevelle at gmail.com
Fri Feb 2 23:03:19 EST 2007

Hey there,

A few weeks back I was thinking of writing a Haskell program that
automated a telnet session.  One function that could be useful is a
hReadUntilStr - that is, a function that takes a Handle as an input
source, a String to match, and a "Num a"  as the number of seconds to
wait before returning a (String, Bool) where the String is all the
text read from the Handle until either matching or timing out and the
Bool is true if the input String was matched.

Something like:

hReadUntilStr :: (Num a) => Handle -> String -> a -> IO (String, Bool)

Is this the wrong way to think about the problem?  If so, how should
it be handled?  If not, any ideas on the implementation?

Any advice is appreciated.


More information about the Haskell-Cafe mailing list