Reputation: 4771
I am exploring the filemanip library to search for markdown files in a path including subfolders
import System.FilePath.Find
find always (fileType ==? RegularFile &&? extension ==? ".md") "a/path/"
is there any way to specify a folder name or pattern into which it should not recurse
Upvotes: 1
Views: 153
Reputation: 2869
Looking at the documentation we can see that find takes as first argument a RecursionPredicate which in turn is just FindClause Bool
.
Based on this we can see that we have to pass in a custom RecursionPredicate
to find
other than always
.
One example is to ignore .git
directories:
notGit :: FindClause Bool -- or via type alias also a RecursionPredicate
notGit = directory /=? ".git"
We then just use our new recursion predicate with find
:
find notGit (fileType ==? RegularFile &&? extension ==? ".md") path
Note also the special combinators for predicates to e.g. compose a notSvn
predicate with our notGit
predicate via (||?)
to get a predicate that enters neither directories.
Upvotes: 4