An abstract data type representing a compiled pattern.
Note that the
Eq instance cannot tell you whether two patterns behave in
the same way; only whether they compile to the same
Pattern. For instance,
may or may not compare equal,
will behave the exact same way no matter which
For the most part, a character matches itself. Recognized operators are as follows:
- Matches any character except path separators.
- Matches any number of characters except path separators, including the empty string.
- Matches any of the enclosed characters. Ranges of characters can be specified by separating the endpoints with a '-'. '-' or ']' can be matched by including them as the first character(s) in the list.
- Like [..], but matches any character not listed.
- Matches any integer in the range m to n, inclusive. The range may be open-ended by leaving out either number: "<->", for instance, matches any integer.
- Matches any number of characters, including path separators, excluding the empty string.
Note that path separators (typically
'/') have to be matched explicitly
or using the
**/ pattern. In addition, extension separators (typically
'.') have to be matched explicitly at the beginning of the pattern or
after any path separator.
If a system supports multiple path separators, any one of them will match
any of them. For instance, on Windows,
'/' will match itself as well as
Erroneous patterns include:
- An empty
<without a matching
- A malformed
<>: e.g. nonnumeric characters or no hyphen
Matches each given
Pattern against the contents of the given
recursively. The result pair's first component contains the matched paths,
grouped for each given
Pattern, and the second contains all paths which
were not matched by any
This function is different from a simple
filter over all the contents of
the directory: the matching is performed relative to the directory, so that
for instance the following is true:
fmap (head.fst) (globDir [compile "*"] dir) == getDirectoryContents dir
"foo" the pattern should be
"foo/*" to get the same
results with a plain
Any results deeper than in the given directory are enumerated lazily, using
Directories without read permissions are returned as entries but their contents, of course, are not.