packages feed

dirfiles 0.1.0.8 → 0.1.0.9

raw patch · 3 files changed

+31/−17 lines, 3 filesdep ~basedep ~unordered-containers

Dependency ranges changed: base, unordered-containers

Files

Data/Library.hs view
@@ -47,8 +47,9 @@  type ItemId = Int -empty :: Library-empty = Seq.empty+empty :: UTCTime -> Library+empty t = Seq.singleton (Item 0 (fromText "/") (Just "The root directory") t t 0 +                        $ Left $ Dir IS.empty IS.empty )  move :: Library -> ItemId -> ItemId -> UTCTime -> Either Error Library  move lib origin destination t = if origin == 0 then Left MovingRoot else do@@ -56,7 +57,7 @@     i <- getItem origin lib         -- item     let parentId = itemParent i     p <- getItem parentId lib       -- parent-    ud <- addItemInDir i d t        -- updated destination+    ud <- insertItemInDir i d t     -- updated destination     up <- rmItemFromDir i p t       -- updated parent     return $ Seq.update destination ud             $ Seq.update parentId up @@ -70,7 +71,7 @@         newItem = i { itemDateModified = t                     , itemId = Seq.length lib                     , itemParent = newParentId }-    ud <- addItemInDir newItem d t  -- add the copy to the destination+    ud <- insertItemInDir newItem d t  -- add the copy to the destination     return $ Seq.update newParentId ud (lib |> newItem)  delete :: Library -> ItemId -> Library@@ -101,10 +102,10 @@ new :: Text -> Maybe Text -> UTCTime -> ItemId -> Maybe UUIRI -> Library      -> Either Error Library new name description creationTime parent uuiri lib = do-    p <- getItem parent lib             -- parent directory-    up <- addItemInDir i p creationTime -- updated parent-    return $ Seq.update parent up       -- updates the library with it-           $ lib |> i                   -- adds the new item to the library+    p <- getItem parent lib                -- parent directory+    up <- insertItemInDir i p creationTime -- updated parent+    return $ Seq.update parent up          -- updates the library with it+           $ lib |> i                      -- adds the new item to the library     where         i = Item (Seq.length lib) (fromText name) (fmap fromText description)                   creationTime creationTime parent $ @@ -115,6 +116,17 @@ unsafeGetItem :: ItemId -> Library -> LibraryItem unsafeGetItem = flip Seq.index  +{-+-- insert the library item into the parent with the ItemId+-- does some tests to ensure consistency+insertItem :: UTCTime -> ItemId -> LibraryItem -> Library -> Either Error Library+insertItem t pid li l = do+    pi      <- getItem iid l of+    let li' = if itemParent li /= pid then li { itemParent = pid } else li+    newp    <- insertItemInDir li' pid t+    return $ Seq.update +-}+ -- | Does bounds checking and also checks if the item was not deleted getItem :: ItemId -> Library -> Either Error LibraryItem getItem i l = if i >= Seq.length l @@ -144,9 +156,11 @@                          , itemType = Left $ Dir (op (itemId item) files) dirs                          } -addItemInDir :: LibraryItem -> LibraryItem -> UTCTime +-- First argument is the item to add, second argument is the parent where the +-- item will be inserted into+insertItemInDir :: LibraryItem -> LibraryItem -> UTCTime               -> Either Error LibraryItem-addItemInDir = itemOpInDir insert +insertItemInDir = itemOpInDir insert   rmItemFromDir :: LibraryItem -> LibraryItem -> UTCTime                -> Either Error LibraryItem@@ -217,7 +231,7 @@  isDir :: LibraryItem -> Bool isDir i = case itemType i of -            Right _ -> True+            Left _ -> True             _ -> False  -- | A directory is just a pair of IntSet's where the first one has the
Data/Library/IRI.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}+{-# LANGUAGE OverloadedStrings, TemplateHaskell, BangPatterns #-} module Data.Library.IRI ( IRI(Relative, Absolute) , toIRI@@ -20,8 +20,8 @@ import Control.Applicative ((<$>)) import Data.SafeCopy (deriveSafeCopy, base) -data IRI = Relative Text-         | Absolute Text+data IRI = Relative !Text+         | Absolute !Text          deriving(Show)  instance ToJSON IRI where
dirfiles.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dirfiles-version:             0.1.0.8+version:             0.1.0.9 -- synopsis:             description:         Simple datatype to represent a library with files and folders license:             BSD3@@ -19,12 +19,12 @@   exposed-modules:     Data.Library, Data.Library.UUIRI, Data.Library.IRI   -- other-modules:          other-extensions:    OverloadedStrings, TemplateHaskell-  build-depends: base                   >=4.6  && <4.7+  build-depends:    base >=4 && < 5                 ,    text >=0.11                 ,    containers >=0.5                 ,    time >=1.4                 ,    aeson >=0.6 -               ,    unordered-containers >=0.2 && <0.3+               ,    unordered-containers >=0.2                 ,    safecopy >=0.8                 ,    hblock >=0.1