summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Identifier
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core/Identifier')
-rw-r--r--src/Hakyll/Core/Identifier/Pattern.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Identifier/Pattern.hs b/src/Hakyll/Core/Identifier/Pattern.hs
index 42f67f0..28e23ad 100644
--- a/src/Hakyll/Core/Identifier/Pattern.hs
+++ b/src/Hakyll/Core/Identifier/Pattern.hs
@@ -47,7 +47,7 @@ import Data.List (isPrefixOf, inits, tails)
import Control.Arrow ((&&&), (>>>))
import Control.Monad (msum)
import Data.Maybe (isJust)
-import Data.Monoid (mempty, mappend)
+import Data.Monoid (Monoid, mempty, mappend)
import GHC.Exts (IsString, fromString)
@@ -68,6 +68,12 @@ data Pattern = Glob [GlobComponent]
instance IsString Pattern where
fromString = parseGlob
+instance Monoid Pattern where
+ mempty = Predicate (const True)
+ g@(Glob _) `mappend` x = Predicate (matches g) `mappend` x
+ x `mappend` g@(Glob _) = x `mappend` Predicate (matches g)
+ Predicate f `mappend` Predicate g = Predicate $ \i -> f i && g i
+
-- | Parse a pattern from a string
--
parseGlob :: String -> Pattern