1
0
forked from GitHub/gf-core

ghc-7.6: allow directory-1.2

Get rid of old-time depend (and ClockTime in favour of UTCTime).
time-compat helps to retain backward compatibility with directory-1.1
and lower.
This commit is contained in:
Sergei Trofimovich
2013-03-09 21:38:43 +00:00
parent 576b19aab5
commit 0173b5f4ff
4 changed files with 17 additions and 14 deletions

View File

@@ -4,11 +4,12 @@ import Control.Concurrent.MVar
import Data.Map (Map)
import qualified Data.Map as Map
import System.Directory (getModificationTime)
import System.Time (ClockTime)
import Data.Time (UTCTime)
import Data.Time.Compat (toUTCTime)
data Cache a = Cache {
cacheLoad :: FilePath -> IO a,
cacheObjects :: MVar (Map FilePath (MVar (Maybe (ClockTime, a))))
cacheObjects :: MVar (Map FilePath (MVar (Maybe (UTCTime, a))))
}
newCache :: (FilePath -> IO a) -> IO (Cache a)
@@ -27,7 +28,7 @@ readCache c file =
Nothing -> do v <- newMVar Nothing
return (Map.insert file v objs, v)
-- Check time stamp, and reload if different than the cache entry
readObject m = do t' <- getModificationTime file
readObject m = do t' <- toUTCTime `fmap` getModificationTime file
x' <- case m of
Just (t,x) | t' == t -> return x
_ -> cacheLoad c file