[Haskell-cafe] Stream-fusion without the lists

Max Rabkin max.rabkin at gmail.com
Tue May 12 13:56:56 EDT 2009


On Tue, May 12, 2009 at 1:39 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
> let xs = map f ys in (sum xs, product xs)
>
> the elements of xs will be computed once if it is a list but twice if it is
> a stream.

If you're using lists for loops rather than data, that's what you want
(what you probably really want is cfoldl' ((,) <$> sumF <*> productF)
xs, in terms of combinable folds).

> Roman

--Max


More information about the Haskell-Cafe mailing list