diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2015-10-17 16:47:51 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-10-17 16:51:33 +0200 |
commit | e8ed2136feea75f4676eb6103acd5bb1bfe35281 (patch) | |
tree | 156daa80421dfdd923d3fa12c83809458f42d333 /compiler/nativeGen | |
parent | 40cbf9aaa16fd263c54e159a4bda3a5682720041 (diff) | |
download | haskell-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/nativeGen')
-rw-r--r-- | compiler/nativeGen/AsmCodeGen.hs | 4 | ||||
-rw-r--r-- | compiler/nativeGen/NCGMonad.hs | 4 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Linear/State.hs | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs index d84578805b..1b57a504bd 100644 --- a/compiler/nativeGen/AsmCodeGen.hs +++ b/compiler/nativeGen/AsmCodeGen.hs @@ -979,11 +979,11 @@ instance Functor CmmOptM where fmap = liftM instance Applicative CmmOptM where - pure = return + pure x = CmmOptM $ \_ _ imports -> (# x, imports #) (<*>) = ap instance Monad CmmOptM where - return x = CmmOptM $ \_ _ imports -> (# x, imports #) + return = pure (CmmOptM f) >>= g = CmmOptM $ \dflags this_mod imports -> case f dflags this_mod imports of diff --git a/compiler/nativeGen/NCGMonad.hs b/compiler/nativeGen/NCGMonad.hs index fcb7b90d0d..35a00270a3 100644 --- a/compiler/nativeGen/NCGMonad.hs +++ b/compiler/nativeGen/NCGMonad.hs @@ -92,12 +92,12 @@ instance Functor NatM where fmap = liftM instance Applicative NatM where - pure = return + pure = returnNat (<*>) = ap instance Monad NatM where (>>=) = thenNat - return = returnNat + return = pure thenNat :: NatM a -> (a -> NatM b) -> NatM b diff --git a/compiler/nativeGen/RegAlloc/Linear/State.hs b/compiler/nativeGen/RegAlloc/Linear/State.hs index 287bdc65e4..9602d251c6 100644 --- a/compiler/nativeGen/RegAlloc/Linear/State.hs +++ b/compiler/nativeGen/RegAlloc/Linear/State.hs @@ -56,12 +56,12 @@ instance Functor (RegM freeRegs) where fmap = liftM instance Applicative (RegM freeRegs) where - pure = return + pure a = RegM $ \s -> (# s, a #) (<*>) = ap instance Monad (RegM freeRegs) where m >>= k = RegM $ \s -> case unReg m s of { (# s, a #) -> unReg (k a) s } - return a = RegM $ \s -> (# s, a #) + return = pure instance HasDynFlags (RegM a) where getDynFlags = RegM $ \s -> (# s, ra_DynFlags s #) |