1313-- License : BSD-style (see LICENSE)
1414-- Maintainer : diagrams-discuss@googlegroups.com
1515--
16- -- Convenient creation of command-line-driven executables for
17- -- rendering diagrams. This module provides a general framework
18- -- and default behaviors for parsing command-line arguments,
19- -- records for diagram creation options in various forms, and
20- -- classes and instances for a unified entry point to command-line-driven
21- -- diagram creation executables.
16+ -- Convenient creation of command-line-driven executables for rendering
17+ -- diagrams. This module provides a general framework and default
18+ -- behaviors for parsing command-line arguments, records for diagram
19+ -- creation options in various forms, and classes and instances for a
20+ -- unified entry point to command-line-driven diagram creation
21+ -- executables.
2222--
2323-- For a tutorial on command-line diagram creation see
2424-- <http://projects.haskell.org/diagrams/doc/cmdline.html>.
@@ -338,6 +338,9 @@ instance (Parseable a, Parseable b) => Parseable (a,b) where
338338instance (Parseable a , Parseable b , Parseable c ) => Parseable (a , b , c ) where
339339 parser = (,,) <$> parser <*> parser <*> parser
340340
341+ instance (Parseable a , Parseable b , Parseable c , Parseable d ) => Parseable (a , b , c , d ) where
342+ parser = (,,,) <$> parser <*> parser <*> parser <*> parser
343+
341344-- | This class allows us to abstract over functions that take some arguments
342345-- and produce a final value. When some @d@ is an instance of
343346-- 'ToResult' we get a type @'Args' d@ that is a type of /all/ the arguments
@@ -576,7 +579,7 @@ defaultLoopRender opts = when (opts ^. loop) $ do
576579 else do
577580 lhsExists <- doesFileExist lhsFile
578581 if lhsExists then return lhsFile
579- else error (" Unable to guess source file\n "
582+ else error (" Unable to guess source file. "
580583 ++ " Specify source file with '-s' or '--src'" )
581584 srcPath' <- canonicalizePath srcPath
582585
@@ -590,16 +593,14 @@ defaultLoopRender opts = when (opts ^. loop) $ do
590593 let srcFilePath = fromText $ T. pack srcPath'
591594 args' = delete " -l" . delete " --loop" $ args
592595 newProg = newProgName (takeFileName srcPath) prog
596+ timeOfDay = take 8 . drop 11 . show . eventTime
593597
594598 -- Polling is only used on Windows
595599 withManagerConf defaultConfig { confPollInterval = opts ^. interval } $
596600 \ mgr -> do
597- _ <- watchDir
598- mgr
599- (directory srcFilePath)
600- (existsEvents (== srcFilePath))
601+ _ <- watchDir mgr (directory srcFilePath) (existsEvents (== srcFilePath))
601602 -- Call the new program without the looping option
602- (\ ev -> putStrF (" Modified " ++ show (eventTime ev) ++ " ... " )
603+ (\ ev -> putStrF (" Modified " ++ timeOfDay ev ++ " ... " )
603604 >> recompile srcPath newProg sandboxArgs >>= run newProg args')
604605 putStrLn $ " Watching source file " ++ srcPath
605606 putStrLn $ " Compiling target: " ++ newProg
0 commit comments