filesystem-trees 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+19/−14 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- filesystem-trees.cabal +1/−1
- src/System/File/Tree.hs +18/−13
filesystem-trees.cabal view
@@ -1,5 +1,5 @@ Name: filesystem-trees-Version: 0.1.0.1+Version: 0.1.0.2 Synopsis: Recursively manipulate and traverse filesystems as lazy rose trees. Cabal-Version: >= 1.10 License: BSD3
src/System/File/Tree.hs view
@@ -127,10 +127,12 @@ -- |Efficiently maps 'FSTree' over a list. This is more efficient than map FSTree mapFSTree :: Forest FilePath -> FSForest mapFSTree = unsafeCoerce+{-# NOINLINE mapFSTree #-} -- |Efficiently maps toTree over a list. This is more effficient than map toTree mapToTree :: FSForest -> Forest FilePath mapToTree = unsafeCoerce+{-# NOINLINE mapToTree #-} -- |Overloaded lenses for 'Tree' and 'FSTree' class TreeLens t a | t -> a where@@ -156,6 +158,7 @@ -- current directories and relative paths apply to the tree as a whole. getDirectory :: FilePath -> IO FSTree getDirectory = getDir_ unsafeInterleaveIO+{-# NOINLINE getDirectory #-} -- |A strict variant of 'getDirectory'. --@@ -181,7 +184,7 @@ isFile :: FilePath -> IO Bool isFile = doesFileExist --- |Checks if a path refer to a directory.+-- |Checks if a path refers to a directory. isDir :: FilePath -> IO Bool isDir = doesDirectoryExist @@ -277,16 +280,18 @@ -- |Monadic 'filter'. filterM :: Monad m => (FilePath -> m Bool) -> FSForest -> m FSForest-filterM p = foldrM (filter' . prependPaths) []- where filter' (Node path cs) ts =- ifM (p path)- (liftM ((:ts) . mkFSTree path) $ foldrM filter' [] cs)- (do- cs' <- foldrM filter' [] $ cs- return $ case cs' of- [] -> ts- _ -> mkFSTree path cs' : ts- )+filterM p = foldrM (filter' "") [] . mapToTree+ where + filter' d (Node file cs) ts = do+ let path = d </> file+ cs' <- foldrM (filter' path) [] cs+ b <- p path+ return $ + if b+ then mkFSTree file cs' : ts+ else case cs' of+ [] -> ts+ _ -> mkFSTree file cs' : ts -- |Monadic 'find'. findM :: Monad m =>@@ -347,7 +352,7 @@ -- |Move a filesystem tree to a new location, deleting any file/directory that -- was present at the given destination path. ----- Directories listed in the source filesystem tree are removed if the move+-- Directories listed in the source filesystem tree are removed from disk if the move -- operation empties their contents completely. The resulting 'FSTree' represents -- all the moved directories/files in their new home. --@@ -450,7 +455,7 @@ -> FilePath -> FSTree -> m ([a], FSTree) zipWithDestM__ f rootDest fs =- liftM2 (,) (sequence $ (zipWith f `on` flatten) fs destFs)+ liftM2 (,) (sequence $ zipWith f (flatten fs) (flatten destFs)) (return destFs) where destFs = setL label rootDest fs