Is there a haskell library function to monitor a file without polling?
With polling i would do someting like this:
monitor file mtime handler = do
threadDelay n -- sleep `n` ns
t <- getModificationTime file
if t > mtime
then handler >> monitor file t handler
else monitor file mtime handler
What I want is something like a blocking getModificationTime which will be woken up by the system. Is there something available?
I would be perfectly happy if it was available for posix systems only, but the more portable the better :-)
Edit: I know hinotify, but I'm on a Mac (that's why I mention POSIX).
hinotity
andkqueue
depending on platform might be interesting. – Illicit