[Haskell-beginners] Data.Foldable's foldr'
Federico Mastellone
fmaste at gmail.com
Wed Jun 15 17:17:46 CEST 2011
Hi,
Looking at the source of Data.Foldable I found something I don't understand
The Foldable class declares foldl like this:
foldl :: (a -> b -> a) -> a -> t b -> a
Them, outside of the class, foldr' is defined like this:
-- | Fold over the elements of a structure,-- associating to the
right, but strictly.foldr' :: Foldable t => (a -> b -> b) -> b -> t a
-> bfoldr' f z0 xs = foldl f' id xs z0 where f' k x z = k $! f x z
I don't understand this definition, foldl receives 3 parameters and
here it is used with 4, how is it possible?
Even the function passed to foldl has 3 parameters when a function of
2 is needed.
What is the precedence and associativity involved here that makes
foldr' a valid expression?
Thanks!
--
Federico Mastellone
Computer Science Engineer - ITBA
".. there are two ways of constructing a software design: One way is to make
it so simple that there are obviously no deficiencies, and the other way is
to make it so complicated that there are no obvious deficiencies. The first
method is far more difficult."
Tony Hoare, 1980 ACM Turing Award Lecture.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110615/36fe3d6a/attachment.htm>
More information about the Beginners
mailing list