diff options
author | David Feuer <David.Feuer@gmail.com> | 2014-10-16 09:44:25 +0200 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2014-10-16 09:45:17 +0200 |
commit | 7e735950a44f7f3c34319ea65631e11e52eb68a7 (patch) | |
tree | d7066a843450be852458a03503691294fcecfe76 /libraries | |
parent | cde3a77f9703966145cae481ee35f52dcca2cf7d (diff) | |
download | haskell-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.hs | 9 |
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. -- |