[Haskell-cafe] foldl in terms of foldr
Eduard Sergeev
Eduard.Sergeev at gmail.com
Tue Jan 26 11:05:30 EST 2010
Neil Brown-7 wrote:
>
> step is of type b -> (a -> a) -> (a -> a), which does agree with (a -> b
> -> b)
Not quite right..
Let's rewite the function:
myFoldl f z xs = foldr (step f) id xs z
step f x g = \a -> g (f a x)
now (from ghci):
step (+) :: (Num t1) => t1 -> (t1 -> t3) -> t1 -> t3
or even:
step (flip (:)) :: t -> ([t] -> t3) -> [t] -> t3
But yes, the type from my first post was wrong
--
View this message in context: http://old.nabble.com/foldl-in-terms-of-foldr-tp27322307p27325072.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list