machines-directory 0.2.0.10 → 0.2.1.0
raw patch · 3 files changed
+21/−13 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- System.Directory.Machine.Internal: joined :: Process [a] a
+ System.Directory.Machine: directoryWalk' :: (FilePath -> Bool) -> ProcessT IO FilePath FilePath
Files
- machines-directory.cabal +1/−1
- src/System/Directory/Machine.hs +19/−4
- src/System/Directory/Machine/Internal.hs +1/−8
machines-directory.cabal view
@@ -1,5 +1,5 @@ name: machines-directory-version: 0.2.0.10+version: 0.2.1.0 synopsis: Directory (system) utilities for the machines library homepage: http://github.com/aloiscochard/machines-directory license: Apache-2.0
src/System/Directory/Machine.hs view
@@ -13,14 +13,29 @@ import System.Directory.Machine.Internal +-- | Recursively (breadth-first) walk thru the directory structure.+--+-- >>> runT (files <~ directoryWalk <~ source ["."])+-- ["./.gitignore",... directoryWalk :: ProcessT IO FilePath FilePath-directoryWalk = MachineT . return $ Await (\root -> f [root] []) Refl stopped where- f [] [] = directoryWalk- f xs (y:ys) = MachineT . return $ Yield y $ f xs ys+directoryWalk = directoryWalk' (const True)++-- | A variant of 'directoryWalk' with a predicate whether to descend+-- into particular directory.+--+-- @+-- directoryWalk' (not . isSuffixOf ".git")+-- @+--+-- @since 0.2.1.0+directoryWalk' :: (FilePath -> Bool) -> ProcessT IO FilePath FilePath+directoryWalk' p = MachineT . return $ Await (\root -> f [root] []) Refl stopped where+ f [] [] = directoryWalk+ f xs (y:ys) = MachineT . return $ Yield y $ f xs ys f (x:xs) [] = MachineT $ do ys <- getDirectoryContents x let contents = (x </>) <$> (filter isDirectoryContentsValid $ ys)- dirs <- filterM doesDirectoryExist contents+ dirs <- filterM doesDirectoryExist (filter p contents) runMachineT $ f (dirs ++ xs) contents directoryContents :: ProcessT IO FilePath [FilePath]
src/System/Directory/Machine/Internal.hs view
@@ -1,13 +1,6 @@ module System.Directory.Machine.Internal where -import Data.Machine---- TODO Contribute to machines?-joined :: Process [a] a-joined = f [] where- f [] = MachineT . return $ Await (\xs -> f xs) Refl stopped- f (x:xs) = MachineT . return $ Yield x $ f xs-+-- | Predicate to filter out relative paths: @"."@ and @".."@. isDirectoryContentsValid :: FilePath -> Bool isDirectoryContentsValid x = (x /= "." && x /= "..")