Commit 57f65911 authored by illissius's avatar illissius Committed by ian@well-typed.com
Browse files

alpha-rename the type signatures of foldl, foldl', and scanl to be consistent with foldr and scanr

parent 6f32757e
......@@ -132,14 +132,14 @@ class Foldable t where
-- | Left-associative fold of a structure.
--
-- @'foldl' f z = 'Prelude.foldl' f z . 'toList'@
foldl :: (a -> b -> a) -> a -> t b -> a
foldl :: (b -> a -> b) -> b -> t a -> b
foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
-- | Left-associative fold of a structure.
-- but with strict application of the operator.
--
-- @'foldl' f z = 'List.foldl'' f z . 'toList'@
foldl' :: (a -> b -> a) -> a -> t b -> a
foldl' :: (b -> a -> b) -> b -> t a -> b
foldl' f z0 xs = foldr f' id xs z0
where f' x k z = k $! f z x
......
......@@ -45,8 +45,8 @@ module Data.List
-- * Reducing lists (folds)
, foldl -- :: (a -> b -> a) -> a -> [b] -> a
, foldl' -- :: (a -> b -> a) -> a -> [b] -> a
, foldl -- :: (b -> a -> b) -> b -> [a] -> b
, foldl' -- :: (b -> a -> b) -> b -> [a] -> b
, foldl1 -- :: (a -> a -> a) -> [a] -> a
, foldl1' -- :: (a -> a -> a) -> [a] -> a
, foldr -- :: (a -> b -> b) -> b -> [a] -> b
......@@ -68,7 +68,7 @@ module Data.List
-- * Building lists
-- ** Scans
, scanl -- :: (a -> b -> a) -> a -> [b] -> [a]
, scanl -- :: (b -> a -> b) -> b -> [a] -> [b]
, scanl1 -- :: (a -> a -> a) -> [a] -> [a]
, scanr -- :: (a -> b -> b) -> b -> [a] -> [b]
, scanr1 -- :: (a -> a -> a) -> [a] -> [a]
......@@ -1004,7 +1004,7 @@ unfoldr f b =
-- -----------------------------------------------------------------------------
-- | A strict version of 'foldl'.
foldl' :: (a -> b -> a) -> a -> [b] -> a
foldl' :: (b -> a -> b) -> b -> [a] -> b
#ifdef __GLASGOW_HASKELL__
foldl' f z0 xs0 = lgo z0 xs0
where lgo z [] = z
......
......@@ -166,7 +166,7 @@ filterFB c p x r | p x = x `c` r
-- can be inlined, and then (often) strictness-analysed,
-- and hence the classic space leak on foldl (+) 0 xs
foldl :: (a -> b -> a) -> a -> [b] -> a
foldl :: (b -> a -> b) -> b -> [a] -> b
foldl f z0 xs0 = lgo z0 xs0
where
lgo z [] = z
......@@ -181,7 +181,7 @@ foldl f z0 xs0 = lgo z0 xs0
--
-- > last (scanl f z xs) == foldl f z xs.
scanl :: (a -> b -> a) -> a -> [b] -> [a]
scanl :: (b -> a -> b) -> b -> [a] -> [b]
scanl f q ls = q : (case ls of
[] -> []
x:xs -> scanl f (f q x) xs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment