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. http://citeseer.ist.psu.edu/jones91unboxed.html John -- John Meacham - ⑆repetae.net⑆john⑈ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe