Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains functionality that involves the interface with FSNotify.
The only important function here is monitor
, next to some reexports from FSNotify.
Synopsis
- monitor :: (MonadUnliftIO m, MonadReader env m, HasLogFunc env, HasWatchManager env, HasEventChannel env event) => [Watch m event] -> m (StopListening m)
- type GlobList = [Text]
- type FileEventHandler m event = Event -> m event
- type Watch m event = (GlobList, FileEventHandler m event)
- type StopListening m = m ()
- withWatchManager :: MonadUnliftIO m => (WatchManager -> m a) -> m a
- data Event
- eventPath :: Event -> FilePath
- data WatchManager
- class HasWatchManager env where
- watchManager :: Lens' env WatchManager
- class HasEventChannel env event where
- eventChannel :: Lens' env (Chan event)
Documentation
monitor :: (MonadUnliftIO m, MonadReader env m, HasLogFunc env, HasWatchManager env, HasEventChannel env event) => [Watch m event] -> m (StopListening m) #
Starts a number of watches, where each watch is specified by a list of
glob-patterns and a handler that converts Event
to a message. Generated
events are pushed to the given channel. Returns an IO action that will stop
all of these watches.
The glob-pattern is expanded such that all directories containing matching files are watched. In addition we also watch these directories if they're empty, so that we trigger on file creation events.
type FileEventHandler m event = Event -> m event #
An event handler, taking an Event
and returning some internal
message type.
type Watch m event = (GlobList, FileEventHandler m event) #
A Watch
is a list of file patterns to watch and a corresponding FileEventHandler
type StopListening m = m () #
Every time we set a watch, we are given a function that, when called, unsets the watch.
withWatchManager :: MonadUnliftIO m => (WatchManager -> m a) -> m a #
Unlifted version of withManager
.
data WatchManager #
class HasWatchManager env where #
RIO class for obtaining the WatchManager
.
watchManager :: Lens' env WatchManager #
class HasEventChannel env event where #
RIO class for obtaining the event channel to which event messages are pushed.
eventChannel :: Lens' env (Chan event) #