summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-02-19 20:29:26 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-02-19 20:39:23 +0100
commit1996052b110b8528e90d76c06e13c0b7e4a2e93a (patch)
tree306aa351fb307feecfc504b9593e6507e38353fb /src
parent2416c76faa0dadb330c74dc0f3ddefdf4f889659 (diff)
downloadhakyll-1996052b110b8528e90d76c06e13c0b7e4a2e93a.tar.gz
Add complement function for patterns
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Identifier/Pattern.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Identifier/Pattern.hs b/src/Hakyll/Core/Identifier/Pattern.hs
index e770d13..5f97215 100644
--- a/src/Hakyll/Core/Identifier/Pattern.hs
+++ b/src/Hakyll/Core/Identifier/Pattern.hs
@@ -36,13 +36,19 @@
-- function.
--
module Hakyll.Core.Identifier.Pattern
- ( Pattern
+ ( -- * The pattern type
+ Pattern
, castPattern
+
+ -- * Creating patterns
, parseGlob
, predicate
, list
, regex
, inGroup
+ , complement
+
+ -- * Applying patterns
, matches
, filterMatches
, capture
@@ -131,6 +137,15 @@ regex str = predicate $ fromMaybe False . (=~~ str) . toFilePath
inGroup :: Maybe String -> Pattern a
inGroup group = predicate $ (== group) . identifierGroup
+-- | Inverts a pattern, e.g.
+--
+-- > complement "foo/bar.html"
+--
+-- will match /anything/ except @\"foo\/bar.html\"@
+--
+complement :: Pattern a -> Pattern a
+complement p = predicate (not . matches p)
+
-- | Check if an identifier matches a pattern
--
matches :: Pattern a -> Identifier a -> Bool