[Haskell-cafe] foldl in terms of foldr
Xingzhi Pan
vengeance.storm at gmail.com
Tue Jan 26 08:04:10 EST 2010
Hi,
I am reading Real World Haskell and have some questions about the
piece of code implementing foldl in terms of foldr:
-- file: ch04/Fold.hs
myFoldl :: (a -> b -> a) -> a -> [b] -> a
myFoldl f z xs = foldr step id xs z
where step x g a = g (f a x)
The first argument to foldr is of type (a -> b -> a), which takes 2
arguments. But 'step' here is defined as a function taking 3
arguments. What am I missing here? (Partial application? The order
of execution?)
Btw, is there a way I can observe the type signature of 'step' in this code?
Thanks in advance!
--
Pan, Xingzhi
http://www.panxingzhi.net
More information about the Haskell-Cafe
mailing list