[Top] [All Lists]

Re: [Haskell-cafe] space leaks and optimizations

Subject: Re: [Haskell-cafe] space leaks and optimizations
From: Henning Thielemann
Date: Fri, 15 Jan 2010 16:40:46 +0100
Ryan Ingram schrieb:

> Hi Alexei, you have a ton of great points but I wanted to discuss an
> issue with this one.
> It's unusual that this is what you want either; since it only reduces
> the state to WHNF.  For example, if your state is a string, this only
> evaluates enough to know whether or not the string is empty at each
> step, and you can still get into trouble with code like this:
>    put ("xxx" ++ some_bad_computation)
> which leave bottoms inside of your state which won't show up until later.
> Several attempts to solve this problem exist, but the most commonly
> used one is the "rnf" strategy from Control.Parallel.Strategies, which
> uses a typeclass to allow each type to specify how to evaluate itself
> completely.

Now available without parallelism in


I think that one should generally think before using seq, because it is
only strict in the top most constructor. If you know the type you 'seq'
on, then you might use a 'case' on it instead and can precisely control
the depth of the strictness. Otherwise you might use 'rnf'.

I have also some problems with space leaks. Recently I found a space
leak in my code, that was because a finalizer did not run as expected.
Now I'm seeking more information on how to use finalizers correctly ...

Haskell-Cafe mailing list

<Prev in Thread] Current Thread [Next in Thread>