From 28f1121e77ea30d50b28d93c30a54b6080f3b350 Mon Sep 17 00:00:00 2001 From: Josh Meredith Date: Fri, 13 Jan 2023 05:29:12 +0000 Subject: Use lazy break for `lines` --- libraries/base/Data/OldList.hs | 2 +- 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) -- cgit v1.2.1