summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-10-29 15:07:55 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-10-29 15:07:55 +0000
commit7d57cec81800f53e6ebb42e84bd1625327902658 (patch)
tree1d41ca9f02300570e7c2b594c62b3b6c7810a3bb
parent3c17388f3a23dbed0a69c6e385d57bac1a91f83e (diff)
parent64d0a198be05c7baff36e43ab96928a402f00a19 (diff)
downloadhaskell-7d57cec81800f53e6ebb42e84bd1625327902658.tar.gz
Merge remote-tracking branch 'origin/master' into wip/new-flatten-skolems-Aug14
-rw-r--r--libraries/base/Data/Bool.hs2
-rw-r--r--libraries/base/Data/Functor.hs6
-rw-r--r--libraries/base/GHC/List.lhs34
-rw-r--r--libraries/base/Text/Printf.hs2
m---------utils/haddock0
5 files changed, 25 insertions, 19 deletions
diff --git a/libraries/base/Data/Bool.hs b/libraries/base/Data/Bool.hs
index ace5acf447..15371982ea 100644
--- a/libraries/base/Data/Bool.hs
+++ b/libraries/base/Data/Bool.hs
@@ -37,7 +37,7 @@ import GHC.Base
--
-- /Since: 4.7.0.0/
--
--- __Examples__:
+-- ==== __Examples__
--
-- Basic usage:
--
diff --git a/libraries/base/Data/Functor.hs b/libraries/base/Data/Functor.hs
index 010ab502e6..0896947417 100644
--- a/libraries/base/Data/Functor.hs
+++ b/libraries/base/Data/Functor.hs
@@ -33,7 +33,7 @@ infixl 4 <$>
-- | An infix synonym for 'fmap'.
--
--- __Examples__:
+-- ==== __Examples__
--
-- Convert from a 'Maybe' 'Int' to a 'Maybe' 'String' using 'show':
--
@@ -70,7 +70,7 @@ infixl 4 $>
--
-- /Since: 4.7.0.0/
--
--- __Examples__:
+-- ==== __Examples__
--
-- Replace the contents of a 'Maybe' 'Int' with a constant 'String':
--
@@ -103,7 +103,7 @@ infixl 4 $>
-- | @'void' value@ discards or ignores the result of evaluation, such
-- as the return value of an 'IO' action.
--
--- __Examples__:
+-- ==== __Examples__
--
-- Replace the contents of a 'Maybe' 'Int' with unit:
--
diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.lhs
index 89c33d66f2..6a930333e0 100644
--- a/libraries/base/GHC/List.lhs
+++ b/libraries/base/GHC/List.lhs
@@ -533,23 +533,29 @@ take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs
#else
--- We always want to inline this to take advantage of a known
--- length argument sign.
-{-# INLINE take #-}
+
+{- We always want to inline this to take advantage of a known length argument
+sign. Note, however, that it's important for the RULES to grab take, rather
+than trying to INLINE take immediately and then letting the RULES grab
+unsafeTake. Presumably the latter approach doesn't grab it early enough; it led
+to an allocation regression in nofib/fft2. -}
+{-# INLINE [1] take #-}
take n xs | 0 < n = unsafeTake n xs
| otherwise = []
-- A version of take that takes the whole list if it's given an argument less
--- than 1. This does the same thing as the fold version.
+-- than 1.
{-# NOINLINE [1] unsafeTake #-}
unsafeTake :: Int -> [a] -> [a]
-unsafeTake _ [] = []
-unsafeTake 1 (x: _) = [x]
-unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs
+unsafeTake !_ [] = []
+unsafeTake 1 (x: _) = [x]
+unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs
{-# RULES
-"unsafeTake" [~1] forall n xs . unsafeTake n xs =
- build (\c nil -> foldr (takeFB c nil) (flipSeqTake nil) xs n)
+"take" [~1] forall n xs . take n xs =
+ build (\c nil -> if 0 < n
+ then foldr (takeFB c nil) (flipSeqTake nil) xs n
+ else nil)
"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeqTake []) xs n
= unsafeTake n xs
#-}
@@ -558,8 +564,8 @@ unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs
-- Just flip seq, specialized to Int, but not inlined too early.
-- It's important to force the numeric argument here, even though
-- it's not used. Otherwise, take n [] doesn't force n. This is
--- bad for strictness analysis and unboxing, and leads to test suite
--- performance regressions.
+-- bad for strictness analysis and unboxing, and leads to increased
+-- allocation in T7257.
flipSeqTake :: a -> Int -> a
flipSeqTake x !_n = x
@@ -602,9 +608,9 @@ drop n ls
-- A version of drop that drops the whole list if given an argument
-- less than 1
unsafeDrop :: Int -> [a] -> [a]
- unsafeDrop _ [] = []
- unsafeDrop 1 (_:xs) = xs
- unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs
+ unsafeDrop !_ [] = []
+ unsafeDrop 1 (_:xs) = xs
+ unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs
#endif
-- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of
diff --git a/libraries/base/Text/Printf.hs b/libraries/base/Text/Printf.hs
index d20e077b95..7cf4204e50 100644
--- a/libraries/base/Text/Printf.hs
+++ b/libraries/base/Text/Printf.hs
@@ -246,7 +246,7 @@ import System.IO
-- * Haskell 'printf' will place a zero after a decimal point when
-- possible.
--
--- Examples:
+-- ==== __Examples__
--
-- > > printf "%d\n" (23::Int)
-- > 23
diff --git a/utils/haddock b/utils/haddock
-Subproject c3f27a96bd2a1ec14f441c72a2df95c16c2c540
+Subproject 3fb325a2ca6b6397905116024922d079447a2e0