This commit is contained in:
Daniel Gröber 2015-08-03 05:39:52 +02:00
parent 75d4a2a9d6
commit 84c0670fc4

View File

@ -25,9 +25,9 @@ data Cached m d a = Cached {
-- optimizazion when knowing which input files changed can make updating the -- optimizazion when knowing which input files changed can make updating the
-- cache faster -- cache faster
-- --
-- * @data@: Arbitrary static input data can be used to invalidate the cache -- * @data@: Arbitrary static input data to cache action. Can be used to
-- using something other than file timestamps i.e. environment tool version -- invalidate the cache using something other than file timestamps
-- numbers -- i.e. environment tool version numbers
-- --
-- * @ma@: Cached data if it existed -- * @ma@: Cached data if it existed
-- --
@ -53,7 +53,7 @@ data TimedCacheFiles = TimedCacheFiles {
} }
-- | Cache a MonadIO action with proper invalidation. -- | Cache a MonadIO action with proper invalidation.
cached :: forall m a d. (MonadIO m, GmLog m, Serialize a, Eq d, Serialize d) cached :: forall m a d. (MonadIO m, GmLog m, Serialize a, Eq d, Serialize d, Show d)
=> FilePath -- ^ Directory to prepend to 'cacheFile' => FilePath -- ^ Directory to prepend to 'cacheFile'
-> Cached m d a -- ^ Cache descriptor -> Cached m d a -- ^ Cache descriptor
-> d -> d
@ -66,7 +66,7 @@ cached dir cd d = do
writeCache (TimedCacheFiles tcfile []) Nothing "cache missing" writeCache (TimedCacheFiles tcfile []) Nothing "cache missing"
Just (ifs, d', a) | d /= d' -> do Just (ifs, d', a) | d /= d' -> do
tcf <- timeCacheInput dir (cacheFile cd) ifs tcf <- timeCacheInput dir (cacheFile cd) ifs
writeCache tcf (Just a) "input data changed" writeCache tcf (Just a) $ "input data changed" -- ++ " was: " ++ show d ++ " is: " ++ show d'
Just (ifs, _, a) -> do Just (ifs, _, a) -> do
tcf <- timeCacheInput dir (cacheFile cd) ifs tcf <- timeCacheInput dir (cacheFile cd) ifs
case invalidatingInputFiles tcf of case invalidatingInputFiles tcf of