
26 Jan
2010
26 Jan
'10
8:04 a.m.
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