aboutsummaryrefslogtreecommitdiff
path: root/Utility/Matcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-09-15 12:50:14 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-09-15 12:50:14 -0400
commitf30be9764801fb265d59fcde69a20b7fac21b1c6 (patch)
tree17e4a709b8d1dceec6f8d6aa9a01d41a84197c2f /Utility/Matcher.hs
parentcfe58e3b364870572bda251f4bae7e6fd415b090 (diff)
Fix bug in combination of preferred and required content settings. When one was set to the empty string and the other set to some expression, this bug caused all files to be wanted, instead of only files matching the expression.
Avoid: MAny `MOr` otherexpression Which matches anything.
Diffstat (limited to 'Utility/Matcher.hs')
-rw-r--r--Utility/Matcher.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Utility/Matcher.hs b/Utility/Matcher.hs
index 19a77201c..d78e597dc 100644
--- a/Utility/Matcher.hs
+++ b/Utility/Matcher.hs
@@ -27,6 +27,7 @@ module Utility.Matcher (
matchM,
matchMrun,
isEmpty,
+ combineMatchers,
prop_matcher_sane
) where
@@ -142,6 +143,14 @@ isEmpty :: Matcher a -> Bool
isEmpty MAny = True
isEmpty _ = False
+{- Combines two matchers, yielding a matcher that will match anything
+ - both do. -}
+combineMatchers :: Matcher a -> Matcher a -> Matcher a
+combineMatchers a b
+ | isEmpty a = b
+ | isEmpty b = a
+ | otherwise = a `MOr` b
+
prop_matcher_sane :: Bool
prop_matcher_sane = all (\m -> match dummy m ()) $ map generate
[ [Operation True]