Does the GHC GC handle const application?

If I create a thunk representing const x y will the garbage collector be sure to replace this with x? I'm just wondering if I have to be concerned about the fact that Data.Sequence defines update in terms of adjust, with update x = adjust (const x)

On Mon, May 30, 2016 at 08:13:41PM -0400, David Feuer wrote:
If I create a thunk representing
const x y
will the garbage collector be sure to replace this with x?
Not until it's evaluated, no.
I'm just wondering if I have to be concerned about the fact that Data.Sequence defines update in terms of adjust, with
update x = adjust (const x)
Could you say more about your concern?

Currently, `adjust` is probably *too* lazy. When called, it places a thunk right at/below the root of the tree. This can lead to thunks building up around the root if multiple nodes are adjusted between inspections. I'm strongly considering modifying it to install its thunk at the appropriate leaf instead. Thinking about this, I realized that even with that modification, calling `update` multiple times on the same index could potentially lead to thunks building up around the leaf, even though this is never necessary. On May 31, 2016 3:20 AM, "Tom Ellis" < tom-lists-haskell-cafe-2013@jaguarpaw.co.uk> wrote:
On Mon, May 30, 2016 at 08:13:41PM -0400, David Feuer wrote:
If I create a thunk representing
const x y
will the garbage collector be sure to replace this with x?
Not until it's evaluated, no.
I'm just wondering if I have to be concerned about the fact that Data.Sequence defines update in terms of adjust, with
update x = adjust (const x)
Could you say more about your concern? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
participants (2)
-
David Feuer
-
Tom Ellis