diff --git a/README.md b/README.md index ba3e316..8c29ca6 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The generated value offers three ```Event```s: The function ```deltaDirWithCallbacks``` gives you an instance of the datatype ```CallbackWatcher``` that wraps a ```FileWatcher```. -You can add an arbitrary number callbacks to instances of that type with: +You can add an arbitrary number of callbacks to instances of that type with: * ```withChangedCallback``` * ```withNewCallback``` diff --git a/delta.cabal b/delta.cabal index d5ff249..9a69f54 100644 --- a/delta.cabal +++ b/delta.cabal @@ -13,10 +13,15 @@ name: delta version: 0.1.0.0 -- A short (one-line) description of the package. -synopsis: A library for detecting changes in files +synopsis: A library for detecting file changes -- A longer description of the package. --- description: +description: Delta is a library for detecting file changes in any given + directory. The package is written using the sodium FRP library + but it also provides a callback based API. + + The project also contains an executable, delta-cli which + runs on the command line and prints detected changes to stdout. -- URL for the project homepage or repository. homepage: https://github.com/kryoxide/delta @@ -46,8 +51,11 @@ build-type: Simple -- extra-source-files: -- Constraint on the version of Cabal needed to build this package. -cabal-version: >=1.10 +cabal-version: >=1.16 +source-repository head + type: git + location: https://github.com/kryoxide/delta/ library -- Modules exported by the library. @@ -63,7 +71,7 @@ library -- other-extensions: -- Other library packages from which modules are imported. - build-depends: base >=4.8 && <4.9 + build-depends: base >=4.6 && <4.9 , containers >= 0.5 , directory >= 1.2 , filepath >= 1.3 @@ -89,4 +97,6 @@ executable delta-cli hs-source-dirs: src/delta-cli - main-is: Main.hs \ No newline at end of file + main-is: Main.hs + + default-language: Haskell2010 \ No newline at end of file diff --git a/src/System/Delta/Callback.hs b/src/System/Delta/Callback.hs index 217a47e..473eb42 100644 --- a/src/System/Delta/Callback.hs +++ b/src/System/Delta/Callback.hs @@ -1,5 +1,22 @@ {-# LANGUAGE GADTs #-} -module System.Delta.Callback where +module System.Delta.Callback ( CallbackWatcher + , CallbackId + + -- * Construction + , withCallbacks + + -- * Adding callbacks + , withDeleteCallback + , withChangedCallback + , withNewCallback + + -- * Removing callbacks + , unregisterCallback + , removeAllCallbacks + + -- * Closing the watcher + , closeCallbackWatcher + )where import FRP.Sodium import System.Delta.Base diff --git a/src/System/Delta/Class.hs b/src/System/Delta/Class.hs index 68a4e3c..e6ed80d 100644 --- a/src/System/Delta/Class.hs +++ b/src/System/Delta/Class.hs @@ -4,9 +4,20 @@ import FRP.Sodium import System.Delta.Base class FileWatcher a where + -- | Each type provides a default watcher for a pass defaultWatcher :: FilePath -> IO a + + -- | An event that gives some info on changed files (disjunct from + -- deleted and new files) changedFiles :: a -> Event FileInfo + + -- | An event that fires for each new file newFiles :: a -> Event FilePath + + -- | An event that fires for each deleted path deletedFiles :: a -> Event FilePath + + -- | Free all possibly used resources. No event will fire after + -- this. cleanUpAndClose :: a -> IO () diff --git a/src/System/Delta/Poll.hs b/src/System/Delta/Poll.hs index 94cf921..e23ede1 100644 --- a/src/System/Delta/Poll.hs +++ b/src/System/Delta/Poll.hs @@ -1,5 +1,8 @@ -module System.Delta.Poll where +module System.Delta.Poll ( PollWatcher + , createPollWatcher + )where +import Control.Applicative ((<$>)) import Control.Concurrent import Control.Monad (foldM) @@ -28,6 +31,8 @@ instance FileWatcher PollWatcher where deletedFiles (PollWatcher _ _ _ e _) = e cleanUpAndClose (PollWatcher _ _ _ _ tId) = killThread tId +-- | Watch files in this directory recursively for changes every +-- n seconds. createPollWatcher :: Int -- ^ seconds interval -> FilePath -- ^ path to watch -> IO PollWatcher