packages feed

filecache 0.2.5 → 0.2.6

raw patch · 2 files changed

+16/−15 lines, 2 filesdep +exceptionsdep ~mtl

Dependencies added: exceptions

Dependency ranges changed: mtl

Files

Data/FileCache.hs view
@@ -15,7 +15,7 @@ import Control.Concurrent.STM import qualified Data.Either.Strict as S import Control.Exception-import Control.Monad.Error.Class+import Control.Monad.Catch import Control.Exception.Lens import Control.Applicative import Control.Monad (join)@@ -29,7 +29,7 @@  -- | Generates a new file cache. The opaque type is for use with other -- functions.-newFileCache :: Error r => IO (FileCacheR r a)+newFileCache :: Exception e => IO (FileCacheR r a) newFileCache = FileCache <$> newTVarIO HM.empty <*> initINotify  -- | Destroys the thread running the FileCache. Pretty dangerous stuff.@@ -37,7 +37,7 @@ killFileCache (FileCache _ ino) = killINotify ino  -- | Manually invalidates an entry.-invalidate :: Error r => FilePath -> FileCacheR r a -> IO ()+invalidate :: Exception e => FilePath -> FileCacheR e a -> IO () invalidate fp (FileCache q _) = join $ atomically $ do     mp <- readTVar q     case HM.lookup fp mp of@@ -52,11 +52,11 @@ -- Queries that fail with an 'IOExeception' will not create a cache entry. -- Also please note that there is a race condition between the potential -- execution of the computation and the establishment of the watch.-query :: Error r-      => FileCacheR r a+query :: Exception e+      => FileCacheR e a       -> FilePath -- ^ Path of the file entry-      -> IO (S.Either r a) -- ^ The computation that will be used to populate the cache-      -> IO (S.Either r a)+      -> IO (S.Either e a) -- ^ The computation that will be used to populate the cache+      -> IO (S.Either e a) query f@(FileCache q ino) fp action = do     mp <- getCache f     case HM.lookup fp mp of@@ -75,11 +75,11 @@                 , handler id           (\e  -> withWatch (S.Left (strMsg $ show e)))                 ] -- | Just like `query`, but with the standard "Either" type.-lazyQuery :: Error r-      => FileCacheR r a-      -> FilePath -- ^ Path of the file entry-      -> IO (Either r a) -- ^ The computation that will be used to populate the cache-      -> IO (Either r a)+lazyQuery :: Exception e r+          => FileCacheR r a+          -> FilePath -- ^ Path of the file entry+          -> IO (Either r a) -- ^ The computation that will be used to populate the cache+          -> IO (Either r a) lazyQuery q fp generate = fmap unstrict (query q fp (fmap strict generate))     where         strict (Left x) = S.Left x@@ -88,6 +88,6 @@         unstrict (S.Right x) = Right x  -- | Gets a copy of the cache.-getCache :: Error r => FileCacheR r a -> IO (HM.HashMap FilePath (S.Either r a, WatchDescriptor))+getCache :: Exception e => FileCacheR e a -> IO (HM.HashMap FilePath (S.Either e a, WatchDescriptor)) getCache (FileCache q _) = atomically (readTVar q) 
filecache.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                filecache-version:             0.2.5+version:             0.2.6 synopsis:            A Linux-only cache system associating values to files. description:         A Linux-only cache system, that works by associating computation results with file names. When the files are modified, the cache entries are discarded. homepage:            http://lpuppet.banquise.net/@@ -31,6 +31,7 @@                      , hashable             >= 1.2   && < 1.3                      , hinotify             >= 0.3.6 && < 0.4                      , strict-base-types    >= 0.2.2-                     , mtl                  == 2.1.*+                     , mtl                  >= 2.1   && < 2.3                      , lens                 >= 3.9 && < 5+                     , exceptions           == 0.6.*                      , stm