summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorDavid Feuer <David.Feuer@gmail.com>2014-10-16 09:44:25 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2014-10-16 09:45:17 +0200
commit7e735950a44f7f3c34319ea65631e11e52eb68a7 (patch)
treed7066a843450be852458a03503691294fcecfe76 /libraries
parentcde3a77f9703966145cae481ee35f52dcca2cf7d (diff)
downloadhaskell-7e735950a44f7f3c34319ea65631e11e52eb68a7.tar.gz
Make tails a good producer (#9670)
Reviewed By: nomeata, austin Differential Revision: https://phabricator.haskell.org/D325
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/Data/OldList.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/libraries/base/Data/OldList.hs b/libraries/base/Data/OldList.hs
index ad2c5105d4..ff8515419a 100644
--- a/libraries/base/Data/OldList.hs
+++ b/libraries/base/Data/OldList.hs
@@ -787,9 +787,12 @@ inits = map toListSB . scanl' snocSB emptySB
-- Note that 'tails' has the following strictness property:
-- @tails _|_ = _|_ : _|_@
tails :: [a] -> [[a]]
-tails xs = xs : case xs of
- [] -> []
- _ : xs' -> tails xs'
+{-# INLINABLE tails #-}
+tails lst = build (\c n ->
+ let tailsGo xs = xs `c` case xs of
+ [] -> n
+ _ : xs' -> tailsGo xs'
+ in tailsGo lst)
-- | The 'subsequences' function returns the list of all subsequences of the argument.
--