title: Monitoring the filesystem with Haskell
body: <p>I'm using the <a href="http://hackage.haskell.org/package/fsnotify-0.0.6" rel="noreferrer">FSNotify</a> package to watch my filesystem for changes to markdown files, so I can run them through <a href="http://johnmacfarlane.net/pandoc/" rel="noreferrer">Pandoc</a> automatically. However, I'm having trouble getting the manager to exit nicely.</p>
  
  <p>As it stands, my code is based on <a href="https://github.com/yesodweb/yesod/blob/master/yesod-bin/Devel.hs#L167" rel="noreferrer">Yesod's use of the same package</a>:</p>
  
  <pre class="lang-hs prettyprint-override"><code>module Main where
  
  import System.FSNotify
  import Filesystem (getWorkingDirectory)
  import System.Exit
  import Control.Concurrent
  
  main = do
      cwd &lt;- getWorkingDirectory
      putStrLn "Watching current directory, press RETURN to exit."
      withManager $ \man -&gt; do
          _ &lt;- forkIO $ do
              watchTree man cwd (const True) $ \fp -&gt; print fp
          _ &lt;- getLine
          exitSuccess
  </code></pre>
  
  <p>When I use <code>runhaskell</code>, the program works perfectly, but if I compile it to an executable (using <code>ghc --make</code>), when I press enter, my terminal becomes unresponsive. I'm compiling this on Windows 7 64-bit.</p>
  
  <p>EDIT: <a href="https://gist.github.com/eightyeight/5591481" rel="noreferrer">Completed code</a>. Well, not entirely completed - there's still more I want to do with this - but working.</p>