Skip to content

Commit

Permalink
Fix strictness of foldl' & foldr'
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumlamm committed Jan 23, 2025
1 parent 6b2e44a commit 81eb408
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Data/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ foldr f z =
foldr' :: forall a b . (a -> b -> b) -> b -> [a] -> b
foldr' f z [] = z
foldr' f z (x:xs) =
let y = foldr f z xs
let y = foldr' f z xs
in y `seq` f x y

foldr1 :: forall a . (a -> a -> a) -> [a] -> a
Expand Down Expand Up @@ -138,7 +138,7 @@ foldl' :: forall a b . (b -> a -> b) -> b -> [a] -> b
foldl' _ z [] = z
foldl' f z (x : xs) =
let y = f z x
in y `seq` foldl f y xs
in y `seq` foldl' f y xs

foldl1 :: forall a . (a -> a -> a) -> [a] -> a
foldl1 _ [] = error "foldl1"
Expand Down

0 comments on commit 81eb408

Please sign in to comment.