[commit: packages/deepseq] master: Minor optimisation for `<$!!>` (3b78f38)
git at git.haskell.org
git at git.haskell.org
Wed Jul 19 21:59:58 UTC 2017
Repository : ssh://git@git.haskell.org/deepseq
On branch : master
Link : http://git.haskell.org/packages/deepseq.git/commitdiff/3b78f384818986a7d249002f83a47f1f637e2d41
>---------------------------------------------------------------
commit 3b78f384818986a7d249002f83a47f1f637e2d41
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sun Apr 16 23:10:19 2017 +0200
Minor optimisation for `<$!!>`
>---------------------------------------------------------------
3b78f384818986a7d249002f83a47f1f637e2d41
Control/DeepSeq.hs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs
index 0a0439f..32d8b7d 100644
--- a/Control/DeepSeq.hs
+++ b/Control/DeepSeq.hs
@@ -244,7 +244,14 @@ force x = x `deepseq` x
--
-- @since 1.4.3.0
(<$!!>) :: (Monad m, NFData b) => (a -> b) -> m a -> m b
+#if MIN_VERSION_base(4,8,0)
+-- Minor optimisation for AMP; this avoids the redundant indirection
+-- through 'return' in case GHC isn't smart enough to optimise it away
+-- on its own
+f <$!!> m = m >>= \x -> pure $!! f x
+#else
f <$!!> m = m >>= \x -> return $!! f x
+#endif
infixl 4 <$!!>
-- | Reduce to weak head normal form
More information about the ghc-commits
mailing list