summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2015-10-17 16:47:51 +0200
committerBen Gamari <ben@smart-cactus.org>2015-10-17 16:51:33 +0200
commite8ed2136feea75f4676eb6103acd5bb1bfe35281 (patch)
tree156daa80421dfdd923d3fa12c83809458f42d333 /compiler/codeGen
parent40cbf9aaa16fd263c54e159a4bda3a5682720041 (diff)
downloadhaskell-e8ed2136feea75f4676eb6103acd5bb1bfe35281.tar.gz
Make Monad/Applicative instances MRP-friendly
This patch refactors pure/(*>) and return/(>>) in MRP-friendly way, i.e. such that the explicit definitions for `return` and `(>>)` match the MRP-style default-implementation, i.e. return = pure and (>>) = (*>) This way, e.g. all `return = pure` definitions can easily be grepped and removed in GHC 8.1; Test Plan: Harbormaster Reviewers: goldfire, alanz, bgamari, quchen, austin Reviewed By: quchen, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1312
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmmExtCode.hs4
-rw-r--r--compiler/codeGen/StgCmmMonad.hs4
2 files changed, 4 insertions, 4 deletions
diff --git a/compiler/codeGen/StgCmmExtCode.hs b/compiler/codeGen/StgCmmExtCode.hs
index 2091d9b358..50015989e0 100644
--- a/compiler/codeGen/StgCmmExtCode.hs
+++ b/compiler/codeGen/StgCmmExtCode.hs
@@ -89,12 +89,12 @@ instance Functor CmmParse where
fmap = liftM
instance Applicative CmmParse where
- pure = return
+ pure = returnExtFC
(<*>) = ap
instance Monad CmmParse where
(>>=) = thenExtFC
- return = returnExtFC
+ return = pure
instance HasDynFlags CmmParse where
getDynFlags = EC (\_ _ d -> do dflags <- getDynFlags
diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs
index 3d055e75bb..3083bfffc4 100644
--- a/compiler/codeGen/StgCmmMonad.hs
+++ b/compiler/codeGen/StgCmmMonad.hs
@@ -118,12 +118,12 @@ instance Functor FCode where
fmap f (FCode g) = FCode $ \i s -> case g i s of (# a, s' #) -> (# f a, s' #)
instance A.Applicative FCode where
- pure = return
+ pure = returnFC
(<*>) = ap
instance Monad FCode where
(>>=) = thenFC
- return = returnFC
+ return = A.pure
{-# INLINE thenC #-}
{-# INLINE thenFC #-}