{-# LANGUAGE OverloadedStrings #-} — for FilePath literals
module Watch where
import System.FSNotify
Copyright By PowCoder代写 加微信 powcoder
import Control.Concurrent ( threadDelay )
import Control.Monad ( forever )
conf = WatchConfig { confDebounce = Debounce 10
, confUsePolling = True
, confPollInterval = 1000
watch :: Action -> FilePath -> IO a
watch action targetDir = withManagerConf conf $ \mgr -> do
— start a watching job (in the background)
watchDir mgr — manager
targetDir — directory to watch
(const True) — predicate
action — action
— sleep forever (until interrupted)
forever $ threadDelay 1000000
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com