Constant space infinite itteration ... solution?

Alastair Reid alastair@reid-consulting-uk.ltd.uk
13 Dec 2002 09:05:49 +0000


> I'm trying to write a non trivial gui in Haskell. At the moment I'm
> using Hugs, and rapidly coming to the conclusion that I should be
> using something else such as GHC.

I've written GUIs and other reactive systems with Hugs and GHC which
did not leak space and, since the bulk of the work was done by X or
Win32 (i.e., standard library code written in C), ran fast enough to
keep up with humans.  I doubt that GHC's speed and optimizations will
fix your problems.  

> As I see it the problem is basically that of tail recursion removal
> or as David Bergman calls it "last call optimisation".

I suspect this may be a red herring.  Space leaks in Haskell are most
often caused by hanging onto unevaluated expressions or by
accidentally hanging onto data that should be garbage.  

You should use a heap profiler to identify the true cause of your
space leaks and then go fix those.  GHC and NHC both contain good heap
profilers.  GHC contains libraries that are most similar to Hugs.

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/