[email protected]
[Top] [All Lists]

[Haskell-cafe] foldl in terms of foldr

Subject: [Haskell-cafe] foldl in terms of foldr
From: Xingzhi Pan
Date: Tue, 26 Jan 2010 21:04:10 +0800
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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>