-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Cross platform library for file change notification. -- -- Cross platform library for file creation, modification, and deletion -- notification. This library builds upon existing libraries for -- platform-specific Window, Mac, and Linux filesystem event -- notification. @package fsnotify @version 0.1 -- | Minimal example: -- --
-- {-# LANGUAGE OverloadedStrings #-} -- for FilePath literals
--
-- import System.FSNotify
-- import Control.Concurrent (threadDelay)
-- import Control.Monad (forever)
--
-- main =
-- withManager $ \mgr -> do
-- -- start a watching job (in the background)
-- watchDir
-- mgr -- manager
-- "." -- directory to watch
-- (const True) -- predicate
-- print -- action
--
-- -- sleep forever (until interrupted)
-- forever $ threadDelay maxBound
--
module System.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 -> Event
Modified :: FilePath -> UTCTime -> Event
Removed :: FilePath -> UTCTime -> Event
type EventChannel = Chan Event
-- | Helper for extracting the time associated with an event.
eventTime :: Event -> UTCTime
-- | Helper for extracting the path associated with an event.
eventPath :: Event -> FilePath
-- | An action to be performed in response to an event.
type Action = Event -> IO ()
-- | A predicate used to determine whether to act on an event.
type ActionPredicate = Event -> Bool
-- | Watch manager. You need one in order to create watching jobs.
data WatchManager
-- | Perform an IO action with a WatchManager in place. Tear down the
-- WatchManager after the action is complete.
withManager :: (WatchManager -> IO a) -> IO a
-- | Start a file watch manager. Directories can only be watched when they
-- are managed by a started watch watch manager. When finished watching.
-- you must release resources via stopManager. It is preferrable
-- if possible to use withManager to handle this automatically.
startManager :: IO WatchManager
-- | Stop a file watch manager. Stopping a watch manager will immediately
-- stop watching for files and free resources.
stopManager :: WatchManager -> IO ()
-- | Default configuration
defaultConfig :: WatchConfig
-- | Watch configuration
data WatchConfig
WatchConfig :: Debounce -> Int -> Bool -> WatchConfig
-- | Debounce configuration
confDebounce :: WatchConfig -> Debounce
-- | Polling interval if polling is used (microseconds)
confPollInterval :: WatchConfig -> Int
-- | Force use of polling, even if a more effective method may be
-- available. This is mostly for testing purposes.
confUsePolling :: WatchConfig -> Bool
-- | This specifies whether events close to each other should be collapsed
-- together, and how close is close enough.
data Debounce
-- | perform debouncing based on the default time interval
DebounceDefault :: Debounce
-- | perform debouncing based on the specified time interval
Debounce :: NominalDiffTime -> Debounce
-- | do not perform debouncing
NoDebounce :: Debounce
-- | Like withManager, but configurable
withManagerConf :: WatchConfig -> (WatchManager -> IO a) -> IO a
-- | Like startManager, but configurable
startManagerConf :: WatchConfig -> IO WatchManager
-- | An action that cancels a watching/listening job
type StopListening = IO ()
-- | Does this manager use polling?
isPollingManager :: WatchManager -> Bool
-- | Watch the immediate contents of a directory by committing an Action
-- for each event. Watching the immediate contents of a directory will
-- only report events associated with files within the specified
-- directory, and not files within its subdirectories. No two events
-- pertaining to the same FilePath will be executed concurrently.
watchDir :: WatchManager -> FilePath -> ActionPredicate -> Action -> IO StopListening
-- | Watch the immediate contents of a directory by streaming events to a
-- Chan. Watching the immediate contents of a directory will only report
-- events associated with files within the specified directory, and not
-- files within its subdirectories.
watchDirChan :: WatchManager -> FilePath -> ActionPredicate -> EventChannel -> IO StopListening
-- | Watch all the contents of a directory by committing an Action for each
-- event. Watching all the contents of a directory will report events
-- associated with files within the specified directory and its
-- subdirectories. No two events pertaining to the same FilePath will be
-- executed concurrently.
watchTree :: WatchManager -> FilePath -> ActionPredicate -> Action -> IO StopListening
-- | Watch all the contents of a directory by streaming events to a Chan.
-- Watching all the contents of a directory will report events associated
-- with files within the specified directory and its subdirectories.
watchTreeChan :: WatchManager -> FilePath -> ActionPredicate -> EventChannel -> IO StopListening
module System.FSNotify.Devel
-- | In the given directory tree, for files with the given file extension
-- perform the given action
treeExtAny :: WatchManager -> FilePath -> Text -> (FilePath -> IO ()) -> IO StopListening
-- | Example of compiling scss files with compass
--
-- -- compass :: WatchManager -> FilePath -> IO () -- compass man dir = do -- putStrLn $ compass ++ encodeString dir -- treeExtExists man dir scss $ fp -> -- when (deploy notElem splitDirectories fp) $ do -- let d = encodeString $ head (splitDirectories rel) -- system cd ++ d ++ && bundle exec compass compile -- return () ---- -- In the given directory tree, watch for any Added and Modified events -- (but ignore Removed events) for files with the given file extension -- perform the given action treeExtExists :: WatchManager -> FilePath -> Text -> (FilePath -> IO ()) -> IO StopListening doAllEvents :: Monad m => (FilePath -> m ()) -> Event -> m () allEvents :: (FilePath -> Bool) -> (Event -> Bool) existsEvents :: (FilePath -> Bool) -> (Event -> Bool)