Skip to content

Commit b094d1d

Browse files
add new test case; improve documentation
1 parent ad08358 commit b094d1d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/System/File/Tree.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,10 @@ filter p = runIdentity . filterM (return . p)
247247
find :: (FilePath -> Bool) -> FSForest -> FSForest
248248
find p = snd . extract p
249249

250-
-- |A generalization of 'find'. The first element of the result
251-
-- represents the forest after removing all subtrees that match the given predicate,
252-
-- and the second element is a list of trees that matched. This could be useful if
253-
-- you want to handle certain directories specially from others within a
254-
-- sub-filesystem.
250+
-- |The first element of the result represents the forest after removing all
251+
-- subtrees that match the given predicate, and the second element is a list of
252+
-- trees that matched. This could be useful if you want to handle certain
253+
-- directories specially from others within a sub-filesystem.
255254
extract :: (FilePath -> Bool) -> FSForest -> (FSForest, FSForest)
256255
extract p = runIdentity . extractM (return . p)
257256

tests/filter.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import System.File.Tree as FS
2+
import Control.Applicative
3+
import System.Directory
4+
import Data.List
5+
6+
main = do
7+
d <- getDirectory =<< getHomeDirectory
8+
print . FS.filter (".mozilla/" `isInfixOf`) . (:[]) $ d
9+

0 commit comments

Comments
 (0)