Re: Revert a CAF?

2011-12-09 Thread wren ng thornton
On 12/7/11 5:03 AM, Simon Marlow wrote: It would be possible, but it's not quite as straightforward as you might think. Suppose you have a program like this: xs = [1..10] evens = filter ((==0) . (`mod` 2)) xs and you fully evaluate evens. Now, GHC will garbage collect xs, because it isn't

Re: Revert a CAF?

2011-12-08 Thread Simon Marlow
On 07/12/11 15:16, Twan van Laarhoven wrote: On 06/12/11 18:48, wren ng thornton wrote: So, I have an optimization/internals question. Does the GHC API have any hooks for being able to revert a CAF to the original expression, thus discarding the previously computed result? ... I could hack

Re: Revert a CAF?

2011-12-07 Thread Simon Marlow
On 06/12/2011 17:48, wren ng thornton wrote: So, I have an optimization/internals question. Does the GHC API have any hooks for being able to revert a CAF to the original expression, thus discarding the previously computed result? The reason I'm wanting this is that I have a particular CAF

Re: Revert a CAF?

2011-12-07 Thread Twan van Laarhoven
On 06/12/11 18:48, wren ng thornton wrote: So, I have an optimization/internals question. Does the GHC API have any hooks for being able to revert a CAF to the original expression, thus discarding the previously computed result? ... I could hack something together based on unsafePerformIO and

RE: Revert a CAF?

2011-12-06 Thread Simon Peyton-Jones
GHCi does this somehow, so it's definitely possible; Simon M will know. | -Original Message- | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-users- | boun...@haskell.org] On Behalf Of wren ng thornton | Sent: 06 December 2011 17:49 | To: GHC-users List |

Re: Revert a CAF?

2011-12-06 Thread John Meacham
Can you use a weak pointer to do what you want? If you keep a weak pointer to the head of your expensive list then itwill be reclaimed at the next major GC I believe. I have used weakpointers for vaugely similar purposes before. I guess a downside is that they will always be reclaimed on GC even