Last active
May 17, 2018 10:35
-
-
Save jhrcek/b763bf2979a1e294db6246534c280093 to your computer and use it in GitHub Desktop.
Haskell script using fsnotify to watch for filesystem events in given dir
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
#!/usr/bin/env stack | |
-- stack script --resolver lts-10.9 --package fsnotify | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Concurrent (threadDelay) | |
import Control.Monad (forever) | |
import System.Environment (getArgs) | |
import System.FSNotify (watchTree, withManager) | |
main :: IO () | |
main = do | |
[dir] <- getArgs | |
withManager $ \mgr -> do | |
watchTree mgr dir (const True) print | |
forever $ threadDelay 1000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment