Skip to content

Commit

Permalink
Changes for preparing for hackage upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
schrammc committed Jun 15, 2015
1 parent 3778137 commit f051e79
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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```
Expand Down
20 changes: 15 additions & 5 deletions delta.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -89,4 +97,6 @@ executable delta-cli

hs-source-dirs: src/delta-cli

main-is: Main.hs
main-is: Main.hs

default-language: Haskell2010
19 changes: 18 additions & 1 deletion src/System/Delta/Callback.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/System/Delta/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()

7 changes: 6 additions & 1 deletion src/System/Delta/Poll.hs
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f051e79

Please sign in to comment.