Skip to content
Browse files

Merge pull request #22 from fryguybob/loop-7.6

`old-time` to `time`
  • Loading branch information...
2 parents ffcc419 + b1a3be6 commit 5f0cf2fea6ffd5faeab6b3c07e5b26ccf0735769 @byorgey byorgey committed Nov 11, 2012
Showing with 16 additions and 5 deletions.
  1. +1 −0 diagrams-cairo.cabal
  2. +15 −5 src/Diagrams/Backend/Cairo/CmdLine.hs
View
1 diagrams-cairo.cabal
@@ -45,6 +45,7 @@ Library
directory,
filepath,
old-time,
+ time,
diagrams-core >= 0.6 && < 0.7,
diagrams-lib >= 0.6 && < 0.7,
cairo >= 0.10.1 && < 0.13,
View
20 src/Diagrams/Backend/Cairo/CmdLine.hs
@@ -66,12 +66,22 @@ import System.Process (runProcess, waitForProcess)
import System.IO (openFile, hClose, IOMode(..),
hSetBuffering, BufferMode(..), stdout)
import System.Exit (ExitCode(..))
-import System.Time (ClockTime, getClockTime)
import Control.Concurrent (threadDelay)
import Control.Exception (catch, SomeException(..), bracket)
#ifdef CMDLINELOOP
import System.Posix.Process (executeFile)
+#if MIN_VERSION_directory(1,2,0)
+import Data.Time.Clock (UTCTime,getCurrentTime)
+type ModuleTime = UTCTime
+getModuleTime :: IO ModuleTime
+getModuleTime = getCurrentTime
+#else
+import System.Time (ClockTime, getClockTime)
+type ModuleTime = ClockTime
+getModuleTime :: IO ModuleTime
+getModuleTime = getClockTime
+#endif
#endif
data DiagramOpts = DiagramOpts
@@ -284,7 +294,7 @@ indexize nDigits i opts = opts { output = output' }
(base, ext) = splitExtension (output opts)
#ifdef CMDLINELOOP
-waitForChange :: Maybe ClockTime -> DiagramOpts -> String -> [String] -> IO ()
+waitForChange :: Maybe ModuleTime -> DiagramOpts -> String -> [String] -> IO ()
waitForChange lastAttempt opts prog args = do
hSetBuffering stdout NoBuffering
go lastAttempt
@@ -304,7 +314,7 @@ waitForChange lastAttempt opts prog args = do
-- of this attempt. Otherwise (if nothing has changed since the
-- last attempt), return @Nothing@. Also return a Bool saying
-- whether a successful recompilation happened.
-recompile :: Maybe ClockTime -> String -> Maybe String -> IO (Bool, Maybe ClockTime)
+recompile :: Maybe ModuleTime -> String -> Maybe String -> IO (Bool, Maybe ModuleTime)
recompile lastAttempt prog mSrc = do
let errFile = prog ++ ".errors"
srcFile = fromMaybe (prog ++ ".hs") mSrc
@@ -321,11 +331,11 @@ recompile lastAttempt prog mSrc = do
then putStrLn "" >> putStrLn (replicate 75 '-') >> readFile errFile >>= putStr
else putStrLn "done."
- curTime <- getClockTime
+ curTime <- getModuleTime
return (status == ExitSuccess, Just curTime)
else return (False, Nothing)
where getModTime f = catch (Just <$> getModificationTime f)
(\(SomeException _) -> return Nothing)
-#endif
+#endif

0 comments on commit 5f0cf2f

Please sign in to comment.
Something went wrong with that request. Please try again.