diff options
author | Austin Seipp <austin@well-typed.com> | 2013-09-11 18:46:54 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2013-09-11 18:47:15 -0500 |
commit | b20cf4ecbf244f091f4084c11ae2350d248ce6ef (patch) | |
tree | d595c6c632773bb4110468c23467f0b339096538 /compiler/prelude/PrelRules.lhs | |
parent | 1ef941a82eafb8f22c19e2643685679d2454c24a (diff) | |
download | haskell-b20cf4ecbf244f091f4084c11ae2350d248ce6ef.tar.gz |
Fix AMP warnings.
Authored-by: David Luposchainsky <dluposchainsky@gmail.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'compiler/prelude/PrelRules.lhs')
-rw-r--r-- | compiler/prelude/PrelRules.lhs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/prelude/PrelRules.lhs b/compiler/prelude/PrelRules.lhs index 64a9f9b912..3b895d8125 100644 --- a/compiler/prelude/PrelRules.lhs +++ b/compiler/prelude/PrelRules.lhs @@ -49,6 +49,7 @@ import Platform import Util import Coercion (mkUnbranchedAxInstCo,mkSymCo,Role(..)) +import Control.Applicative ( Applicative(..), Alternative(..) ) import Control.Monad import Data.Bits as Bits import qualified Data.ByteString as BS @@ -540,6 +541,13 @@ mkBasicRule op_name n_args rm newtype RuleM r = RuleM { runRuleM :: DynFlags -> InScopeEnv -> [CoreExpr] -> Maybe r } +instance Functor RuleM where + fmap = liftM + +instance Applicative RuleM where + pure = return + (<*>) = ap + instance Monad RuleM where return x = RuleM $ \_ _ _ -> Just x RuleM f >>= g = RuleM $ \dflags iu e -> case f dflags iu e of @@ -547,6 +555,10 @@ instance Monad RuleM where Just r -> runRuleM (g r) dflags iu e fail _ = mzero +instance Alternative RuleM where + empty = mzero + (<|>) = mplus + instance MonadPlus RuleM where mzero = RuleM $ \_ _ _ -> Nothing mplus (RuleM f1) (RuleM f2) = RuleM $ \dflags iu args -> |