diff options
author | Josh Meredith <joshmeredith2008@gmail.com> | 2023-01-13 05:29:12 +0000 |
---|---|---|
committer | Josh Meredith <joshmeredith2008@gmail.com> | 2023-01-24 11:21:56 +0000 |
commit | 28f1121e77ea30d50b28d93c30a54b6080f3b350 (patch) | |
tree | b44113af006fa9329cf2ff9ab649abb86e197761 | |
parent | 6ca3a5128441387d2b57ecfdba18755e9815da14 (diff) | |
download | haskell-wip/strict-break.tar.gz |
Use lazy break for `lines`wip/strict-break
-rw-r--r-- | libraries/base/Data/OldList.hs | 2 | ||||
-rw-r--r-- | libraries/base/GHC/List.hs | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/libraries/base/Data/OldList.hs b/libraries/base/Data/OldList.hs index 8e610ebba0..a2f2950cb9 100644 --- a/libraries/base/Data/OldList.hs +++ b/libraries/base/Data/OldList.hs @@ -1615,7 +1615,7 @@ lines "" = [] -- so s' keeps a reference to the first line via the pair and we have -- a space leak (cf. #4334). -- So we need to make GHC see the selector thunks with a trick. -lines s = cons (case break (== '\n') s of +lines s = cons (case break_ (== '\n') s of (l, s') -> (l, case s' of [] -> [] _:s'' -> lines s'')) diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs index e5c4878ea1..6d393adf99 100644 --- a/libraries/base/GHC/List.hs +++ b/libraries/base/GHC/List.hs @@ -34,7 +34,7 @@ module GHC.List ( head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, - take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, + take, drop, splitAt, takeWhile, dropWhile, span, break, break_, reverse, zip, zip3, zipWith, zipWith3, unzip, unzip3, errorEmptyList, @@ -1094,15 +1094,15 @@ span p xs@(x:xs') -- ([1,2,3],[]) -- -- 'break' @p@ is equivalent to @'span' ('not' . p)@. -break, break' :: (a -> Bool) -> [a] -> ([a],[a]) +break, break_, break' :: (a -> Bool) -> [a] -> ([a],[a]) #if defined(USE_REPORT_PRELUDE) break_ p = span (not . p) #else -- HBC version (stolen) --- break_ _ xs@[] = (xs, xs) --- break_ p xs@(x:xs') --- | p x = ([],xs) --- | otherwise = let (ys,zs) = break_ p xs' in (x:ys,zs) +break_ _ xs@[] = (xs, xs) +break_ p xs@(x:xs') + | p x = ([],xs) + | otherwise = let (ys,zs) = break_ p xs' in (x:ys,zs) #endif break' _ xs@[] = (xs, xs) |