summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Identifier
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-05 11:50:46 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-05 11:50:46 +0200
commitecf4c64f620db72495289f7bce182bf262dc4de4 (patch)
treed6d34276aa4ce262334376d737035f4368f2d296 /src/Hakyll/Core/Identifier
parentb7059a0f1a05db0b2e33efae935ece65f97ea3fc (diff)
downloadhakyll-ecf4c64f620db72495289f7bce182bf262dc4de4.tar.gz
Monoid instance for pattern
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