diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-16 12:28:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-16 12:28:17 -0400 |
commit | 771052a85e3a000911e8a438012e61b3caf9c1a8 (patch) | |
tree | 068b19c71758dca9ec76a1d07c8c291806419765 /Utility/Matcher.hs | |
parent | b06336fa3a146e9a0ef1a1307b1fc219570795c6 (diff) |
optimize monadic ||
(||) used applicative style runs both conditions rather than short
circuiting. Add an orM that properly short-circuits.
Diffstat (limited to 'Utility/Matcher.hs')
-rw-r--r-- | Utility/Matcher.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Utility/Matcher.hs b/Utility/Matcher.hs index 01500a211..71e1e17f4 100644 --- a/Utility/Matcher.hs +++ b/Utility/Matcher.hs @@ -25,7 +25,7 @@ module Utility.Matcher ( matchesAny ) where -import Control.Monad +import Common {- A Token can be an Operation of an arbitrary type, or one of a few - predefined peices of syntax. -} @@ -87,8 +87,8 @@ matchM :: Monad m => Matcher (v -> m Bool) -> v -> m Bool matchM m v = go m where go MAny = return True - go (MAnd m1 m2) = liftM2 (&&) (go m1) (go m2) - go (MOr m1 m2) = liftM2 (||) (go m1) (go m2) + go (MAnd m1 m2) = andM (go m1) (go m2) + go (MOr m1 m2) = orM (go m1) (go m2) go (MNot m1) = liftM not (go m1) go (MOp o) = o v |