[Haskell-cafe] Explicit garbage collection

Dan Doel dan.doel at gmail.com
Wed Jan 6 09:06:51 EST 2010


On Wednesday 06 January 2010 8:52:10 am Miguel Mitrofanov wrote:
> Is there any kind of "ST" monad that allows to know if some STRef is no
>  longer needed?
> 
> The problem is, I want to send some data to an external storage over a
>  network and get it back later, but I don't want to send unnecessary data.
> 
> I've managed to do something like that with weak pointers,
>  System.Mem.performGC and unsafePerformIO, but it seems to me that invoking
>  GC every time is an overkill.
> 
> Oh, and I'm ready to trade the purity of runST for that, if necessary.

You may be able to use something like Oleg's Lightweight Monadic Regions to 
get this effect. I suppose it depends somewhat on what qualifies a reference 
as "no longer needed".

  http://www.cs.rutgers.edu/~ccshan/capability/region-io.pdf

I'm not aware of anything out-of-the-box that does what you want, though.

-- Dan


More information about the Haskell-Cafe mailing list