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/stgSyn | |
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/stgSyn')
-rw-r--r-- | compiler/stgSyn/CoreToStg.hs | 4 | ||||
-rw-r--r-- | compiler/stgSyn/StgLint.hs | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/compiler/stgSyn/CoreToStg.hs b/compiler/stgSyn/CoreToStg.hs index dc70851205..e5954ab440 100644 --- a/compiler/stgSyn/CoreToStg.hs +++ b/compiler/stgSyn/CoreToStg.hs @@ -990,11 +990,11 @@ instance Functor LneM where fmap = liftM instance Applicative LneM where - pure = return + pure = returnLne (<*>) = ap instance Monad LneM where - return = returnLne + return = pure (>>=) = thenLne instance MonadFix LneM where diff --git a/compiler/stgSyn/StgLint.hs b/compiler/stgSyn/StgLint.hs index b415b4f2d9..ef5dd9237a 100644 --- a/compiler/stgSyn/StgLint.hs +++ b/compiler/stgSyn/StgLint.hs @@ -314,13 +314,14 @@ instance Functor LintM where fmap = liftM instance Applicative LintM where - pure = return + pure a = LintM $ \_loc _scope errs -> (a, errs) (<*>) = ap + (*>) = thenL_ instance Monad LintM where - return a = LintM $ \_loc _scope errs -> (a, errs) + return = pure (>>=) = thenL - (>>) = thenL_ + (>>) = (*>) thenL :: LintM a -> (a -> LintM b) -> LintM b thenL m k = LintM $ \loc scope errs |