-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Get filesystem notifications as a stream of events
--   
--   Please see the README and docs at
--   <a>https://www.stackage.org/package/fsnotify-conduit</a>
@package fsnotify-conduit
@version 0.1.1.1

module Data.Conduit.FSNotify

-- | Watch for changes to a directory, and yield the file paths downstream.
--   Typical usage would be:
--   
--   <pre>
--   sourceFileChanges (setRelative False $ mkFileChangeSettings dir)
--   </pre>
sourceFileChanges :: MonadResource m => FileChangeSettings -> ConduitM i Event m ()

-- | The same as <a>sourceFileChanges</a>, but returned in an
--   <a>Acquire</a>. This is slightly clunkier to use than
--   <a>sourceFileChanges</a>, but provides two benefits:
--   
--   <ul>
--   <li>It does not require <a>MonadResource</a></li>
--   <li>You are guaranteed that the directory will be watched immediately.
--   With <a>sourceFileChanges</a>, watching will only commence once you
--   <a>await</a> for the first change.</li>
--   </ul>
acquireSourceFileChanges :: MonadIO m => FileChangeSettings -> Acquire (ConduitM i Event m ())

-- | Settings for watching for file changes, to be passed in to
--   <a>sourceFileChanges</a>. Should be created with
--   <a>mkFileChangeSettings</a>.
data FileChangeSettings

-- | Create a <a>FileChangeSettings</a> from a directory to watch. Provides
--   defaults which can be overridden by the setter functions in this
--   module, such as <a>setRelative</a>.
mkFileChangeSettings :: FilePath -> FileChangeSettings

-- | Override the <a>WatchConfig</a> when creating the <a>WatchManager</a>.
--   
--   Default: <a>defaultConfig</a>
setWatchConfig :: WatchConfig -> FileChangeSettings -> FileChangeSettings

-- | Whether to provide paths relative to the root directory
--   (<tt>True</tt>) or absolute paths (<tt>False</tt>).
--   
--   Default: <a>True</a> (relative paths)
setRelative :: Bool -> FileChangeSettings -> FileChangeSettings

-- | Recursively watch a directory tree?
--   
--   Default: <a>True</a>
setRecursive :: Bool -> FileChangeSettings -> FileChangeSettings

-- | Predicate used to filter events.
--   
--   Default: <tt>const True</tt> (allow all events)
setPredicate :: (Event -> Bool) -> FileChangeSettings -> FileChangeSettings

-- | 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 -> Bool -> Event
Modified :: FilePath -> UTCTime -> Bool -> Event
Removed :: FilePath -> UTCTime -> Bool -> Event
Unknown :: FilePath -> UTCTime -> String -> 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

-- | 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 multiple events from the same file should be
--   collapsed together, and how close is close enough.
--   
--   This is performed by ignoring any event that occurs to the same file
--   until the specified time interval has elapsed.
--   
--   Note that the current debouncing logic may fail to report certain
--   changes to a file, potentially leaving your program in a state that is
--   not consistent with the filesystem.
--   
--   Make sure that if you are using this feature, all changes you make as
--   a result of an <a>Event</a> notification are both non-essential and
--   idempotent.
data Debounce

-- | perform debouncing based on the default time interval of 1 millisecond
DebounceDefault :: Debounce

-- | perform debouncing based on the specified time interval
Debounce :: NominalDiffTime -> Debounce

-- | do not perform debouncing
NoDebounce :: Debounce
