{-# LANGUAGE OverloadedStrings #-} module Foo where import Control.Concurrent (threadDelay) import System.Directory.Watchman (readNotification, subscribe, withConnect, watch) import System.Directory.Watchman.Expression (true, dirname) import System.Directory.Watchman.Fields (FileFieldLabel (..)) import System.Directory.Watchman.Subscribe (SubscriptionName (SubscriptionName)) import System.Directory.Watchman.WFilePath (WFilePath (WFilePath)) test1 :: IO () test1 = do watchRsp <- watch "/home/wutu/tmp/watchman/watchman-v2021.02.15.00-linux/sock" (WFilePath "/home/wutu/projects/hs-watchman") print watchRsp withConnect "/home/wutu/tmp/watchman/watchman-v2021.02.15.00-linux/sock" $ \socket -> do sub <- subscribe socket (WFilePath "/home/wutu/projects/hs-watchman") (SubscriptionName "sub1") (dirname (WFilePath "src")) [] [FLname, FLexists, FLtype, FLsize] print "Waiting..." notif <- readNotification sub print notif notif <- readNotification sub print notif print "DONE"