reflex-fsnotify (empty) → 0.1.0.0
raw patch · 5 files changed
+94/−0 lines, 5 filesdep +basedep +fsnotifydep +reflex
Dependencies added: base, fsnotify, reflex
Files
- ChangeLog.md +5/−0
- LICENSE +30/−0
- README.md +3/−0
- reflex-fsnotify.cabal +29/−0
- src/Reflex/FSNotify.hs +27/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for reflex-fsnotify++## 0.1.0.0++* Initial release containing `watchDirectory`.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2018, Obsidian Systems LLC++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Obsidian Systems LLC nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# reflex-fsnotify++Watch directories for changes using a functional-reactive interface!
+ reflex-fsnotify.cabal view
@@ -0,0 +1,29 @@+cabal-version: >=1.10+name: reflex-fsnotify+version: 0.1.0.0+synopsis: reflex-frp interface for watching files+description: Receive FRP events whenever files change.+bug-reports: https://github.com/reflex-frp/reflex-fsnotify/issues+license: BSD3+license-file: LICENSE+author: Obsidian Systems LLC+maintainer: maintainer@obsidian.systems+copyright: 2020 Obsidian Systems LLC+category: System, FRP+build-type: Simple+extra-source-files: ChangeLog.md+ README.md+tested-with: GHC ==8.6.5 || ==8.4.4++library+ exposed-modules: Reflex.FSNotify+ build-depends: base >=4.10 && <4.13+ , fsnotify >= 0.3 && < 0.4+ , reflex >= 0.5 && < 0.7+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall++source-repository head+ type: git+ location: https://github.com/reflex-frp/reflex-fsnotify
+ src/Reflex/FSNotify.hs view
@@ -0,0 +1,27 @@+{-|+Module: Reflex.FSNotify+Description: Watch for filesystem changes in reflex+-}++{-# LANGUAGE FlexibleContexts #-}+module Reflex.FSNotify where++import Control.Concurrent+import Control.Monad+import Control.Monad.IO.Class+import Reflex+import qualified System.FSNotify as FS++-- | Watch a directory for changes+watchDirectory+ :: (Reflex t, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m))+ => FS.WatchConfig+ -> Event t FilePath+ -> m (Event t FS.Event)+watchDirectory cfg path =+ performEventAsync $ ffor path $ \p cb -> liftIO $ void $ forkIO $+ FS.withManagerConf cfg $ \mgr -> do+ _ <- FS.watchTree mgr p (const True) cb+ forever $ threadDelay 1000000++