diff options
Diffstat (limited to 'test.icl')
-rw-r--r-- | test.icl | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -5,24 +5,35 @@ 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 0 +# (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 <<< "Do something with file1 or file2\n" +# io = io <<< "You have 10 seconds to do something with file1 or file2\n" # (ok,w) = fclose io w -# (inot, w) = inotify_loop_forever inot w +# (inot, w) = inotify_loop_with_timeout (Just 10000) inot w = inotify_close inot where - echo :: String INEvent (Maybe String) Int *World -> *(Int, *World) - echo fname ev f i w + 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 - = (i, w) + = (Void, w) instance <<< (Maybe a) | <<< a where |