HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulefsnotify-0.4.4.0Haskell2010

System.FSNotify

This library does not currently report changes made to directories, only files within watched directories.

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 1000000
  • 10 types
  • 13 values
  • Packagefsnotify-0.4.4.0
  • Exports23
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFSNotify.hs

Events

5 declarations
datadata Event
#

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).

Instances2Eq, Show
  • Eq EventDefined in fsnotify-0.4.4.0 · System.FSNotify.Types
  • Show EventDefined in fsnotify-0.4.4.0 · System.FSNotify.Types
typetype Action = Event -> IO ()
#

An action to be performed in response to an event.

Starting/Stopping

4 declarations
datadata WatchManager
#

Watch manager. You need one in order to create watching jobs.

valuewithManager :: (WatchManager -> IO a) -> IO a
#

Perform an IO action with a WatchManager in place. Tear down the WatchManager after the action is complete.

Start a file watch manager. Directories can only be watched when they are managed by a started watch manager. When finished watching. you must release resources via stopManager. It is preferrable if possible to use withManager to handle this automatically.

valuestopManager :: WatchManager -> IO ()
#

Stop a file watch manager. Stopping a watch manager will immediately stop watching for files and free resources.

Configuration

7 declarations
datadata WatchMode
#

Method of watching for changes.

Constructors

datadata ThreadingMode
#

Constructors

  • SingleThread

    Use a single thread for the entire Manager. Event handler callbacks will run sequentially.

  • ThreadPerWatch

    Use a single thread for each watch (i.e. each call to watchDir, watchTree, etc.). Callbacks within a watch will run sequentially but callbacks from different watches may be interleaved.

  • ThreadPerEvent

    Launch a separate thread for every event handler.

Lower level

3 declarations
typetype StopListening = IO ()
#

An action that cancels a watching/listening job.

Watching

4 declarations

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.