iteratee [PATCH] add enumFollowFd, fileDriverFollowFd

Conrad Parker conrad at metadecks.org
Tue Aug 24 20:29:12 EDT 2010


The attached patch for iteratee-0.3 adds an enumerator to follow a
growing file descriptor (like tail -f), and a variant of fileDriver
that uses it. The two functions are:

-- |The enumerator of a POSIX File Descriptor: a variation of enumFd
-- that follows the tail of growing input.
enumFdFollow :: forall s el a.(ReadableChunk s el) =>
  Fd ->
  EnumeratorGM s el IO a

-- |Process a file using the given IterateeGM.  This function wraps
-- enumFdFollow as a convenience.
-- The first iteratee is used to scan through to the end of the file, using
-- enumFd. The second iteratee is used from then onwards on the growing tail
-- of the file, using enumFdFollow.
fileDriverFollowFd :: (ReadableChunk s el) =>
  IterateeG s el IO a ->
  (a -> IterateeG s el IO b) ->
  FilePath ->
  IO b

The purpose of the two iteratees used by fileDriverFollowFd is that
the first is used to accumulate state over the pre-existing part
of the file, and the second is used to process the growing part of the file.

cheers,

Conrad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-enumfollowfd_-filedriverfollowfd.dpatch
Type: application/octet-stream
Size: 3333 bytes
Desc: not available
Url : http://projects.haskell.org/pipermail/iteratee/attachments/20100825/684739c2/attachment.obj 


More information about the Iteratee mailing list