Repository : ssh://darcs.haskell.org//srv/darcs/packages/base On branch : master
http://hackage.haskell.org/trac/ghc/changeset/63f608643f337b8b0cc28cd73c0653e4088eabbb >--------------------------------------------------------------- commit 63f608643f337b8b0cc28cd73c0653e4088eabbb Author: Gábor Lehel <[email protected]> Date: Sun Oct 14 16:23:53 2012 +0200 alpha-rename the type signatures of foldl, foldl', and scanl to be consistent with foldr and scanr >--------------------------------------------------------------- Data/Foldable.hs | 4 ++-- Data/List.hs | 8 ++++---- GHC/List.lhs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Data/Foldable.hs b/Data/Foldable.hs index 4449ca9..afd9afa 100644 --- a/Data/Foldable.hs +++ b/Data/Foldable.hs @@ -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 diff --git a/Data/List.hs b/Data/List.hs index c3d1a84..7a05939 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -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 diff --git a/GHC/List.lhs b/GHC/List.lhs index 5dfd1ac..b32cea9 100644 --- a/GHC/List.lhs +++ b/GHC/List.lhs @@ -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)
_______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
