[Haskell-cafe] multiple computations, same input

John Meacham john at repetae.net
Wed Mar 29 01:04:42 EST 2006

On Tue, Mar 28, 2006 at 12:27:43PM -0800, Greg Fitzgerald wrote:
> >
> > ...Anyway, I can't help but think that there might be a happy medium
> > between eager and lazy evaluation.
> What I'd love to see is the compiler continue to be call-by-need, but be
> smart enough to recognize when multiple expressions will all eventually need
> to be evaluated.  A simple example:
>     show (a + b)
> (+) requires *both* 'a' and 'b' be evaluated to show the result, not 'a'
> *then* 'b'.  It'd be great if the compiler can seek out any shared lazy data
> structures in evaluating 'a' and 'b', and start computing them both with one
> element at a time.
> Has anyone put any thought into something like this?

This is called strictness analysis and is a fundamental optimization of
any haskell compiler. 

this paper has information on how this information is used in ghc, and a
search for 'strictness analysis' will turn up a plethora of algorithms
for calculating it.



John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell-Cafe mailing list