milkshake-0.1.0.0: Minimal build system combining Dhall, Shake and FSNotify.
Safe HaskellNone
LanguageHaskell2010

Milkshake.Monitor

Description

This module contains functionality that involves the interface with FSNotify. The only important function here is monitor, next to some reexports from FSNotify.

Synopsis

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 GlobList = [Text] #

File paths are expanded with Glob. Input to Watch functionality, i.e. a list of file patterns should follow this type.

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 Event #

Instances

Instances details
Eq Event 
Instance details

Defined in System.FSNotify.Types

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Show Event 
Instance details

Defined in System.FSNotify.Types

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

class HasWatchManager env where #

RIO class for obtaining the WatchManager.

Methods

watchManager :: Lens' env WatchManager #

class HasEventChannel env event where #

RIO class for obtaining the event channel to which event messages are pushed.

Methods

eventChannel :: Lens' env (Chan event) #