[Haskell-cafe] Suggestions for a hReadUntilStr implementation

Greg Fitzgerald garious at gmail.com
Sat Feb 3 16:24:38 EST 2007

Hi Matt,

> 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

This might work for you: http://hpaste.org/289.

It throws an IO exception if hWaitForChar times out, and makes use of lazy
evaluation to schedule all the IO upfront so that grabbing the string prefix
can be done in pure code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070203/126bdfbf/attachment.htm

More information about the Haskell-Cafe mailing list