On Aug 19, 2011 12:44 PM, "Tom Murphy" <amindfv@gmail.com> wrote:
> On Fri, Aug 19, 2011 at 2:52 AM, Daniel Fischer <daniel.is.fischer@googlemail.com> wrote:
>> [...] In most cases, you'll get recomputation,
>> but GHC does a bit of CSE, so in some cases it will compute only once and
>> share the result (which may be a bad thing - that's a further reason for
>> not doing too much CSE, sometimes sharing has catastrophic results).
>
> This is a beginner's list, so I'll ask: what catastrophic result could it have, if it's computing pure functions? 

Catastrophic means nontermination, usually due to the stack or heap getting blown out. The classic example of catastrophic CSE is one of the simplest: computing the average of a list that won't fit in memory, such as [1..100000000000]. CSE, manual or automatic, would hold the entire list in memory, while manually fusing the sum and count operations over a fold runs in constant memory. Last I heard, GHC still didn't detect even that simple case, although it does handle some others.

--
...tabula non rasa. ++bsa