packages feed

hashed-storage 0.5.4 → 0.5.5

raw patch · 2 files changed

+22/−23 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Storage.Hashed.Monad: instance (Functor m, Monad m, MonadError e m) => TreeRO (TreeMonad m)
- Storage.Hashed.Monad: instance (Functor m, Monad m, MonadError e m) => TreeRW (TreeMonad m)
+ Storage.Hashed.Monad: instance (Functor m, Monad m) => TreeRO (TreeMonad m)
+ Storage.Hashed.Monad: instance (Functor m, Monad m) => TreeRW (TreeMonad m)
- Storage.Hashed.Monad: copy :: (TreeRW m, MonadError e m) => AnchoredPath -> AnchoredPath -> m ()
+ Storage.Hashed.Monad: copy :: TreeRW m => AnchoredPath -> AnchoredPath -> m ()
- Storage.Hashed.Monad: createDirectory :: (TreeRW m, MonadError e m) => AnchoredPath -> m ()
+ Storage.Hashed.Monad: createDirectory :: TreeRW m => AnchoredPath -> m ()
- Storage.Hashed.Monad: directoryExists :: (TreeRO m, MonadError e m) => AnchoredPath -> m Bool
+ Storage.Hashed.Monad: directoryExists :: TreeRO m => AnchoredPath -> m Bool
- Storage.Hashed.Monad: exists :: (TreeRO m, MonadError e m) => AnchoredPath -> m Bool
+ Storage.Hashed.Monad: exists :: TreeRO m => AnchoredPath -> m Bool
- Storage.Hashed.Monad: fileExists :: (TreeRO m, MonadError e m) => AnchoredPath -> m Bool
+ Storage.Hashed.Monad: fileExists :: TreeRO m => AnchoredPath -> m Bool
- Storage.Hashed.Monad: readFile :: (TreeRO m, MonadError e m) => AnchoredPath -> m ByteString
+ Storage.Hashed.Monad: readFile :: TreeRO m => AnchoredPath -> m ByteString
- Storage.Hashed.Monad: rename :: (TreeRW m, MonadError e m) => AnchoredPath -> AnchoredPath -> m ()
+ Storage.Hashed.Monad: rename :: TreeRW m => AnchoredPath -> AnchoredPath -> m ()
- Storage.Hashed.Monad: replaceItem :: (MonadError e m, Functor m, Monad m) => AnchoredPath -> Maybe (TreeItem m) -> TreeMonad m ()
+ Storage.Hashed.Monad: replaceItem :: (Functor m, Monad m) => AnchoredPath -> Maybe (TreeItem m) -> TreeMonad m ()
- Storage.Hashed.Monad: runTreeMonad :: (Functor m, MonadError e m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m)
+ Storage.Hashed.Monad: runTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m)
- Storage.Hashed.Monad: unlink :: (TreeRW m, MonadError e m) => AnchoredPath -> m ()
+ Storage.Hashed.Monad: unlink :: TreeRW m => AnchoredPath -> m ()
- Storage.Hashed.Monad: virtualTreeMonad :: (Functor m, MonadError e m, Monad m) => TreeMonad m a -> Tree m -> m (a, Tree m)
+ Storage.Hashed.Monad: virtualTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> Tree m -> m (a, Tree m)
- Storage.Hashed.Monad: withDirectory :: (TreeRO m, MonadError e m) => AnchoredPath -> m a -> m a
+ Storage.Hashed.Monad: withDirectory :: TreeRO m => AnchoredPath -> m a -> m a
- Storage.Hashed.Monad: writeFile :: (TreeRW m, MonadError e m) => AnchoredPath -> ByteString -> m ()
+ Storage.Hashed.Monad: writeFile :: TreeRW m => AnchoredPath -> ByteString -> m ()

Files

Storage/Hashed/Monad.hs view
@@ -22,7 +22,6 @@ import Storage.Hashed.Tree import Storage.Hashed.Hash -import Control.Monad.Error( catchError, MonadError ) import Control.Applicative( (<$>) )  import Data.List( sortBy )@@ -57,25 +56,25 @@  class (Functor m, Monad m) => TreeRO m where     currentDirectory :: m AnchoredPath-    withDirectory :: (MonadError e m) => AnchoredPath -> m a -> m a-    expandTo :: (MonadError e m) => AnchoredPath -> m AnchoredPath+    withDirectory :: AnchoredPath -> m a -> m a+    expandTo :: AnchoredPath -> m AnchoredPath     -- | Grab content of a file in the current Tree at the given path.-    readFile :: (MonadError e m) => AnchoredPath -> m BL.ByteString+    readFile :: AnchoredPath -> m BL.ByteString     -- | Check for existence of a node (file or directory, doesn't matter).-    exists :: (MonadError e m) => AnchoredPath -> m Bool+    exists :: AnchoredPath -> m Bool     -- | Check for existence of a directory.-    directoryExists :: (MonadError e m) => AnchoredPath -> m Bool+    directoryExists ::AnchoredPath -> m Bool     -- | Check for existence of a file.-    fileExists :: (MonadError e m) => AnchoredPath -> m Bool+    fileExists :: AnchoredPath -> m Bool  class TreeRO m => TreeRW m where     -- | Change content of a file at a given path. The change will be     -- eventually flushed to disk, but might be buffered for some time.-    writeFile :: (MonadError e m) => AnchoredPath -> BL.ByteString -> m ()-    createDirectory :: (MonadError e m) => AnchoredPath -> m ()-    unlink :: (MonadError e m) => AnchoredPath -> m ()-    rename :: (MonadError e m) => AnchoredPath -> AnchoredPath -> m ()-    copy   :: (MonadError e m) => AnchoredPath -> AnchoredPath -> m ()+    writeFile :: AnchoredPath -> BL.ByteString -> m ()+    createDirectory :: AnchoredPath -> m ()+    unlink :: AnchoredPath -> m ()+    rename :: AnchoredPath -> AnchoredPath -> m ()+    copy   :: AnchoredPath -> AnchoredPath -> m ()  initialState :: Tree m -> (TreeItem m -> m Hash)                 -> (AnchoredPath -> TreeItem m -> TreeMonad m (TreeItem m)) -> TreeState m@@ -86,19 +85,19 @@                                 , maxage = 0                                 , update = u } -flush :: (Functor m, MonadError e m, Monad m) => TreeMonad m ()+flush :: (Functor m, Monad m) => TreeMonad m () flush = do current <- get            changed' <- map fst <$> M.toList <$> gets changed            dirs' <- gets tree >>= \t -> return [ path | (path, SubTree s) <- list t ]            modify $ \st -> st { changed = M.empty, changesize = 0 }            forM_ (changed' ++ dirs' ++ [AnchoredPath []]) flushItem -runTreeMonad' :: (Functor m, MonadError e m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m)+runTreeMonad' :: (Functor m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m) runTreeMonad' action initial = do   (out, final, _) <- runRWST action (AnchoredPath []) initial   return (out, tree final) -runTreeMonad :: (Functor m, MonadError e m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m)+runTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m) runTreeMonad action initial = do   let action' = do x <- action                    flush@@ -110,7 +109,7 @@ -- to their effect of writing a modified tree to disk). The actions can do both -- read and write -- reads are passed through to the actual filesystem, but the -- writes are held in memory in a form of modified Tree.-virtualTreeMonad :: (Functor m, MonadError e m, Monad m) => TreeMonad m a -> Tree m -> m (a, Tree m)+virtualTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> Tree m -> m (a, Tree m) virtualTreeMonad action t = runTreeMonad' action $                                initialState t (\_ -> return NoHash) (\_ x -> return x) @@ -120,7 +119,7 @@ -- | Modifies an item in the current Tree. This action keeps an account of the -- modified data, in changed and changesize, for subsequent flush -- operations. Any modifications (as in "modifyTree") are allowed.-modifyItem :: (MonadError e m, Functor m, Monad m)+modifyItem :: (Functor m, Monad m)             => AnchoredPath -> Maybe (TreeItem m) -> TreeMonad m () modifyItem path item = do   path' <- (`catPaths` path) `fmap` currentDirectory@@ -149,13 +148,13 @@ -- 'sync' implementation for a particular storage format. The presumed use-case -- is that an existing in-memory Blob is replaced with a one referring to an -- on-disk file.-replaceItem :: (MonadError e m, Functor m, Monad m)+replaceItem :: (Functor m, Monad m)             => AnchoredPath -> Maybe (TreeItem m) -> TreeMonad m () replaceItem path item = do   path' <- (`catPaths` path) `fmap` currentDirectory   modify $ \st -> st { tree = modifyTree (tree st) path' item } -flushItem :: forall e m. (Monad m, MonadError e m, Functor m) => AnchoredPath -> TreeMonad m ()+flushItem :: forall e m. (Monad m, Functor m) => AnchoredPath -> TreeMonad m () flushItem path =   do current <- gets tree      case find current path of@@ -173,7 +172,7 @@   -- | If buffers are becoming large, sync, otherwise do nothing.-flushSome :: (Monad m, MonadError e m, Functor m) => TreeMonad m ()+flushSome :: (Monad m, Functor m) => TreeMonad m () flushSome = do x <- gets changesize                when (x > megs 100) $ do                  remaining <- go =<< sortBy age <$> M.toList <$> gets changed@@ -188,7 +187,7 @@         megs = (* (1024 * 1024))         age (_, (_, a)) (_, (_, b)) = compare a b -instance (Functor m, Monad m, MonadError e m) => TreeRO (TreeMonad m) where+instance (Functor m, Monad m) => TreeRO (TreeMonad m) where     expandTo p =         do t <- gets tree            p' <- (`catPaths` p) `fmap` ask@@ -225,7 +224,7 @@       dir' <- expandTo dir       local (\old -> dir') act -instance (Functor m, Monad m, MonadError e m) => TreeRW (TreeMonad m) where+instance (Functor m, Monad m) => TreeRW (TreeMonad m) where     writeFile p con =         do expandTo p            modifyItem p (Just blob)
hashed-storage.cabal view
@@ -1,5 +1,5 @@ name:          hashed-storage-version:       0.5.4+version:       0.5.5 synopsis:      Hashed file storage support code.  description:   Support code for reading and manipulating hashed file storage