{-# 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 :: IO () test1 = do WatchResponse watchRsp <- WatchmanSockFile -> WFilePath -> IO WatchResponse watch WatchmanSockFile "/home/wutu/tmp/watchman/watchman-v2021.02.15.00-linux/sock" (ByteString -> WFilePath WFilePath ByteString "/home/wutu/projects/hs-watchman") WatchResponse -> IO () forall a. Show a => a -> IO () print WatchResponse watchRsp WatchmanSockFile -> (WatchmanSocket -> IO ()) -> IO () forall a. WatchmanSockFile -> (WatchmanSocket -> IO a) -> IO a withConnect WatchmanSockFile "/home/wutu/tmp/watchman/watchman-v2021.02.15.00-linux/sock" ((WatchmanSocket -> IO ()) -> IO ()) -> (WatchmanSocket -> IO ()) -> IO () forall a b. (a -> b) -> a -> b $ \WatchmanSocket socket -> do WatchmanSubscription sub <- WatchmanSocket -> WFilePath -> SubscriptionName -> Expression -> [SubscribeParams -> SubscribeParams] -> [FileFieldLabel] -> IO WatchmanSubscription subscribe WatchmanSocket socket (ByteString -> WFilePath WFilePath ByteString "/home/wutu/projects/hs-watchman") (ByteString -> SubscriptionName SubscriptionName ByteString "sub1") (WFilePath -> Expression dirname (ByteString -> WFilePath WFilePath ByteString "src")) [] [FileFieldLabel FLname, FileFieldLabel FLexists, FileFieldLabel FLtype, FileFieldLabel FLsize] WatchmanSockFile -> IO () forall a. Show a => a -> IO () print WatchmanSockFile "Waiting..." SubscriptionNotification notif <- WatchmanSubscription -> IO SubscriptionNotification readNotification WatchmanSubscription sub SubscriptionNotification -> IO () forall a. Show a => a -> IO () print SubscriptionNotification notif SubscriptionNotification notif <- WatchmanSubscription -> IO SubscriptionNotification readNotification WatchmanSubscription sub SubscriptionNotification -> IO () forall a. Show a => a -> IO () print SubscriptionNotification notif WatchmanSockFile -> IO () forall a. Show a => a -> IO () print WatchmanSockFile "DONE"