summaryrefslogtreecommitdiff
path: root/Utility/Matcher.hs
diff options
context:
space:
mode:
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..badf72acf 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. But, if one matcher contains no limits, yield the other one. -}
+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]