module test import StdFile import Data.Either import Data.Maybe import Inotify :: Void = Void /** * test: Example usage of Inotify * * This will show all events on files file1 and file2. They should exist before * starting this program. * * When nothing has happened for 10s, the program will exit. */ Start w # (Just inot) = inotify_init Void # (Right watch, inot) = inotify_add_watch (echo "file1") IN_ALL_EVENTS "file1" inot # (Right watch, inot) = inotify_add_watch (echo "file2") IN_ALL_EVENTS "file2" inot # (io,w) = stdio w # io = io <<< "You have 10 seconds to do something with file1 or file2\n" # (ok,w) = fclose io w # (inot, w) = inotify_loop_with_timeout (Just 10000) inot w = inotify_close inot where echo :: String INEvent (Maybe String) Void *World -> *(Void, *World) echo fname ev f _ w # (io,w) = stdio w # io = io <<< "EVENT: ["<<< fname <<<"; "<<< ev <<<"; "<<< f <<<"]\n" # (ok,w) = fclose io w = (Void, w) instance <<< (Maybe a) | <<< a where (<<<) f Nothing = f (<<<) f (Just x) = f <<< x