Search code examples
haskellhaskell-turtle

Finding all the files under a directory in turtle that match a pattern


I'd like to use the find function from the turtle package such that it matches any file path (in order to get an equivalent behavior to find . in bash). However I cannot find a wildcard pattern that I can use with this function.

find :: Pattern a -> FilePath -> Shell FilePath

I guess I could construct a pattern that matches any character zero or more times, but I'd like to avoid re-inventing the wheel.


Solution

  • lsif sounds more like what you want. The documentation contains an example how to print the complete tree:

    lstree = lsif (\_ -> return True)
    

    So in your case, you would use

    lstree "."
    

    Note that the output between find and lstree "." differs slightly: the original path isn't duplicated in the latter.