diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-05 11:50:46 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-05 11:50:46 +0200 |
commit | ecf4c64f620db72495289f7bce182bf262dc4de4 (patch) | |
tree | d6d34276aa4ce262334376d737035f4368f2d296 | |
parent | b7059a0f1a05db0b2e33efae935ece65f97ea3fc (diff) | |
download | hakyll-ecf4c64f620db72495289f7bce182bf262dc4de4.tar.gz |
Monoid instance for pattern
-rw-r--r-- | src/Hakyll/Core/Identifier/Pattern.hs | 8 |
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 |