-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Folder watching as a Streamly stream. -- -- Provides Streamly streams for both single-level and recursive folder -- watching. Also contains a principled and compositional system for -- filtering file system events. @package streamly-fsnotify @version 2.0 -- | Example -- -- Here is a program which watches /home/georgefst/c-project and -- any of its subdirectories for added or modified C source files (which -- we take to be anything with a .c extension). This program -- then writes that the event occurred, to what file, and when, forever. -- --
--   import Data.Functor.Contravariant (Predicate (Predicate))
--   import Streamly.Data.Fold qualified as SF
--   import Streamly.Data.Stream.Prelude qualified as SP
--   import System.FilePath (isExtensionOf, (</>))
--   
--   import Streamly.FSNotify
--   
--   isCSourceFile :: Predicate Event
--   isCSourceFile = Predicate \e ->
--       "c" `isExtensionOf` eventPath e && eventIsDirectory e == IsFile
--   
--   notDeletion :: Predicate Event
--   notDeletion = Predicate \case
--       Removed{} -> False
--       _ -> True
--   
--   srcPath :: FilePath
--   srcPath = "/" </> "home" </> "gthomas" </> "c-project"
--   
--   main :: IO ()
--   main = SP.fold (SF.drainMapM go) $ watchTree srcPath $ isCSourceFile <> notDeletion
--     where
--       go = \case
--           Added p t _ -> putStrLn $ "Created: " ++ show p ++ " at " ++ show t
--           Modified p t _ -> putStrLn $ "Modified: " ++ show p ++ " at " ++ show t
--           _ -> pure ()
--   
module Streamly.FSNotify -- | A file event reported by a file watcher. Each event contains the -- canonical path for the file and a timestamp guaranteed to be after the -- event occurred (timestamps represent current time when FSEvents -- receives it from the OS and/or platform-specific Haskell modules). data Event Added :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory Modified :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory ModifiedAttributes :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory Removed :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory -- | Note: Linux-only WatchedDirectoryRemoved :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory -- | Note: Linux-only CloseWrite :: FilePath -> UTCTime -> EventIsDirectory -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory -- | Note: Linux-only Unknown :: FilePath -> UTCTime -> EventIsDirectory -> String -> Event [eventPath] :: Event -> FilePath [eventTime] :: Event -> UTCTime [eventIsDirectory] :: Event -> EventIsDirectory [eventString] :: Event -> String data EventIsDirectory IsFile :: EventIsDirectory IsDirectory :: EventIsDirectory -- | Watch a given directory, but only at one level (thus, subdirectories -- will not be watched recursively). watchDir :: (MonadAsync m, MonadCatch m) => FilePath -> Predicate Event -> Stream m Event -- | Watch a given directory recursively (thus, subdirectories will also -- have their contents watched). watchTree :: (MonadAsync m, MonadCatch m) => FilePath -> Predicate Event -> Stream m Event