compact-1.0.0.0: In memory storage of deeply evaluated data structure

Copyright (c) The University of Glasgow 2001-2009 (c) Giovanni Campagna 2014 BSD-style (see the file LICENSE) libraries@haskell.org unstable non-portable (GHC Extensions) None Haskell2010

Data.Compact

Description

This module provides a data structure, called a Compact, for holding fully evaluated data in a consecutive block of memory.

Since: 1.0.0

Synopsis

# Documentation

data Compact a Source #

A Compact contains fully evaluated, pure, and immutable data. If any object in the compact is alive, then the whole compact is alive. This means that Compacts are very cheap to keep around, because the data inside a compact does not need to be traversed by the garbage collector. However, the tradeoff is that the memory that contains a Compact cannot be recovered until the whole Compact is garbage.

getCompact :: Compact a -> a Source #

Retrieve the object that was stored in a Compact

inCompact :: Compact b -> a -> IO Bool Source #

Check if the second argument is inside the Compact

isCompact :: a -> IO Bool Source #

Check if the argument is in any Compact

newCompact :: NFData a => Word -> a -> IO (Compact a) Source #

Create a new Compact, with the provided value as suggested block size (which will be adjusted if unsuitable), and append the given value to it, as if calling appendCompact

newCompactNoShare :: NFData a => Word -> a -> IO (Compact a) Source #

Create a new Compact, but append the value using appendCompactNoShare

appendCompact :: NFData a => Compact b -> a -> IO (Compact a) Source #

Append a value to a Compact, and return a new Compact that shares the same buffer but a different root object.

appendCompactNoShare :: NFData a => Compact b -> a -> IO (Compact a) Source #

Append a value to a Compact. This function differs from appendCompact in that it will not preserve internal sharing in the passed in value (and it will diverge on cyclic structures).