[Haskell] memory management
sigbjorn.finne at gmail.com
Tue Aug 4 10:11:09 EDT 2009
staying in the realm of the explicit and pragmatic, various libraries
in Haskell do provide safe&explicit region/alloca/stack allocation
Foreign.Marshal.Alloc.allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
with the promise that the pointer doesn't escape here (you could constrain
this using the type system, if you so wish..) I don't know if the GHC
provides hooks for allocating "alloca" objects specially.
There's been some work on monadic regions too; worth looking at.
On 8/4/2009 15:49, Simon Marlow wrote:
> On 04/08/2009 13:33, Sam Martin wrote:
>>> Sounds like region inference to me.
>> Thanks, yes, that's exactly what I had in mind.
>> Is anything like this is done in GHC?
> Not at the moment, no.
> Bear in mind that with generational GC, allocating memory that quickly
> becomes garbage is quite cheap.
More information about the Haskell