77c6de303f
- Remove nonexistent confDebounce field from WatchConfig (fsnotify 0.4.4.0) - Remove unused Generic deriving and GHC.Generics import - Replace .!= with fromMaybe (not re-exported by Data.Yaml) - Add missing Data.Text import in Main.hs - Use git -C flag in runGitIn to run in the correct repo directory - Clean up unused imports
36 lines
815 B
Haskell
36 lines
815 B
Haskell
{-# LANGUAGE NumericUnderscores #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Main where
|
|
|
|
import Control.Concurrent
|
|
import Data.String.Interpolate
|
|
import System.FSNotify
|
|
import System.FilePath
|
|
import UnliftIO.Temporary
|
|
|
|
|
|
main :: IO ()
|
|
main = do
|
|
withSystemTempDirectory "fsnotify-foo" $ \dir -> do
|
|
putStrLn [i|Starting watch on dir: #{dir}|]
|
|
|
|
let conf = defaultConfig
|
|
|
|
withManagerConf conf $ \mgr -> do
|
|
stop <- watchDir mgr dir (const True) $ \ev -> do
|
|
putStrLn [i|Got event: #{ev}|]
|
|
threadDelay 3_000_000
|
|
|
|
putStrLn [i|Writing to #{dir </> "bar"}|]
|
|
writeFile (dir </> "bar") "asdf"
|
|
threadDelay 3_000_000
|
|
|
|
putStrLn [i|Stopping|]
|
|
stop
|
|
putStrLn [i|Stopped|]
|
|
threadDelay 3_000_000
|
|
|
|
putStrLn [i|Exited withManagerConf|]
|
|
threadDelay 3_000_000
|