module test import StdFile import Data.Either import Data.Maybe import Inotify Start w # (Just inot) = inotify_init 0 # (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 <<< "Do something with file1 or file2\n" # (ok,w) = fclose io w # (inot, w) = inotify_loop_forever inot w = inotify_close inot where echo :: String INEvent (Maybe String) Int *World -> *(Int, *World) echo fname ev f i w # (io,w) = stdio w # io = io <<< "EVENT: ["<<< fname <<<"; "<<< ev <<<"; "<<< f <<<"]\n" # (ok,w) = fclose io w = (i, w) instance <<< (Maybe a) | <<< a where (<<<) f Nothing = f (<<<) f (Just x) = f <<< x