From f2edfd5037e6dd4fa10e00b64cbd62f6cc50daa1 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 21 May 2016 10:48:26 +0200 Subject: Also pass event->name through; inotify_loop_forever --- test.icl | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'test.icl') diff --git a/test.icl b/test.icl index bcb64a9..b598c0f 100644 --- a/test.icl +++ b/test.icl @@ -11,21 +11,20 @@ Start w = 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) = loop inot w +# (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 - loop :: !*(Inotify st) !*World -> *(*Inotify st, *World) - loop inot w - # inot = inotify_poll inot - # (inot, w) = inotify_check inot w - = loop inot w - - echo :: String INEvent Int *World -> *(Int, *World) - echo fname ev i w - # (io,w) = stdio w - # io = io <<< "EVENT: [" <<< fname <<< "; " <<< ev <<< "]\n" - # (ok,w) = fclose io w + 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 -- cgit v1.2.3