Re: Why does this blow the stack?
On Fri, Dec 21, 2007 at 03:16:17PM -0800, David Benbennick wrote:
> On Dec 21, 2007 2:30 PM, Don Stewart <dons <at> galois.com> wrote:
> > dbenbenn:
> > > Thanks for fixing this. But doesn't GHC have strictness analysis?
> >
> > Sure does!
> >
> > The problem here was an explicit recusive loop though,
> > with just not enough for the strictness analyser to get going.
>
> The explicit loop you're talking about is:
> enumDeltaInteger :: Integer -> Integer -> [Integer]
> enumDeltaInteger x d = x : enumDeltaInteger (x+d) d
> That code isn't very complicated, and I would hope to be able to write
> code like that in my own programs without having to worry about
> strictness. Given that the compiler even has an explicit signature,
> why can't it transform that code to
> enumDeltaInteger x d = let s = x + d in x : (seq s $ enumDeltaInteger s d)
> since it knows that (Integer+Integer) is strict? Of course, improving
> the strictness analysis is harder, but it pays off more, too.
Because they simply aren't the same.
Try applying your functions to undefined undefined.
Stefan
_______________________________________________
Haskell-Cafe mailing list
(Continue reading)