-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify some file watching code (#14)
* Fix 7.6.3 build * Simplify tree-watching code
- Loading branch information
1 parent
1a1d2ce
commit 07aa97d
Showing
7 changed files
with
109 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ dist/** | |
cabal.sandbox.config | ||
.stack-work/ | ||
.sosrc* | ||
codex.tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | A streaming wrapper around System.FSNotify. | ||
|
||
module System.FSNotify.Streaming | ||
( System.FSNotify.Streaming.watchTree | ||
-- * Re-exports | ||
, Event(..) | ||
, WatchManager | ||
, defaultConfig | ||
) where | ||
|
||
import Control.Concurrent.Chan | ||
import Control.Monad | ||
import Control.Monad.Trans.Resource | ||
import Streaming | ||
import Streaming.Prelude (yield) | ||
import System.FSNotify | ||
|
||
watchTree | ||
:: MonadResource m | ||
=> WatchConfig -> FilePath -> (Event -> Bool) -> Stream (Of Event) m a | ||
watchTree config path predicate = do | ||
chan <- liftIO newChan | ||
(_, manager) <- allocate (startManagerConf config) stopManager | ||
_ <- allocate (watchTreeChan manager path predicate chan) id | ||
|
||
forever (liftIO (readChan chan) >>= yield) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters