From e737a5126dcfdd0610587d2ec16bea6481cf2a42 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Mon, 12 Oct 2015 11:36:01 +0200 Subject: base: MRP-refactoring of AMP instances This refactors `(>>)`/`(*>)`/`return`/`pure` methods into normal form. The redundant explicit `return` method definitions are dropped altogether. The explicit `(>>) = (*>)` definitions can't be removed yet, as the default implementation of `(>>)` is still in terms of `(*>)` (even though that should have been changed according to the AMP but wasn't -- see note in GHC.Base for details why this had to be postponed) A nofib comparision shows this refactoring to result in minor runtime improvements (unless those are within normal measurement fluctuations): Program Size Allocs Runtime Elapsed TotalMem ------------------------------------------------------------------------- Min -0.0% -0.0% -1.6% -3.9% -1.1% Max -0.0% +0.0% +0.5% +0.5% 0.0% Geometric Mean -0.0% -0.0% -0.4% -0.5% -0.0% Full `nofib` report at https://phabricator.haskell.org/P68 Reviewers: quchen, alanz, austin, #core_libraries_committee, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1316 --- libraries/base/Data/Monoid.hs | 3 --- 1 file changed, 3 deletions(-) (limited to 'libraries/base/Data/Monoid.hs') diff --git a/libraries/base/Data/Monoid.hs b/libraries/base/Data/Monoid.hs index c5a4d8bdf9..eff3836396 100644 --- a/libraries/base/Data/Monoid.hs +++ b/libraries/base/Data/Monoid.hs @@ -82,7 +82,6 @@ instance Applicative Dual where (<*>) = coerce instance Monad Dual where - return = Dual m >>= k = k (getDual m) -- | The monoid of endomorphisms under composition. @@ -126,7 +125,6 @@ instance Applicative Sum where (<*>) = coerce instance Monad Sum where - return = Sum m >>= k = k (getSum m) -- | Monoid under multiplication. @@ -146,7 +144,6 @@ instance Applicative Product where (<*>) = coerce instance Monad Product where - return = Product m >>= k = k (getProduct m) -- $MaybeExamples -- cgit v1.2.1