aboutsummaryrefslogtreecommitdiff
path: root/Utility/Matcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-08 13:16:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-08 13:16:53 -0400
commit45d50d8c27207fa09e5d3331683e1510df3f3bdd (patch)
tree4bc41f75b77aebd09f7343d9d5bca355d57f4536 /Utility/Matcher.hs
parent7057ce97cce7622051815cf8dd6c8ddd5ac0f62c (diff)
wired preferred content up to get, copy, and drop --auto
Diffstat (limited to 'Utility/Matcher.hs')
-rw-r--r--Utility/Matcher.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Utility/Matcher.hs b/Utility/Matcher.hs
index 83a2b1d61..6e88aa100 100644
--- a/Utility/Matcher.hs
+++ b/Utility/Matcher.hs
@@ -23,6 +23,7 @@ module Utility.Matcher (
generate,
match,
matchM,
+ matchM2,
matchesAny
) where
@@ -96,6 +97,15 @@ matchM m v = go m
go (MNot m1) = liftM not (go m1)
go (MOp o) = o v
+matchM2 :: Monad m => Matcher (v1 -> v2 -> m Bool) -> v1 -> v2 -> m Bool
+matchM2 m v1 v2 = go m
+ where
+ go MAny = return True
+ go (MAnd m1 m2) = go m1 <&&> go m2
+ go (MOr m1 m2) = go m1 <||> go m2
+ go (MNot m1) = liftM not (go m1)
+ go (MOp o) = o v1 v2
+
{- Checks is a matcher contains no limits, and so (presumably) matches
- anything. Note that this only checks the trivial case; it is possible
- to construct matchers that match anything but are more complicated. -}