compact- In memory storage of deeply evaluated data structure

Copyright(c) The University of Glasgow 2001-2009 (c) Giovanni Campagna <> 2015
LicenseBSD-style (see the file LICENSE)
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone



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

This module contains support for serializing a Compact for network transmission and on-disk storage.

Since: 1.0.0



data SerializedCompact a Source #

A serialized version of the Compact metadata (each block with address and size and the address of the root). This structure is meant to be sent alongside the actual Compact data. It can be sent out of band in advance if the data is to be sent over RDMA (which requires both sender and receiver to have pinned buffers).

withSerializedCompact :: NFData c => Compact a -> (SerializedCompact a -> IO c) -> IO c Source #

Serialize the Compact, and call the provided function with with the Compact serialized representation. The resulting action will be executed synchronously before this function completes.

importCompact :: SerializedCompact a -> (Ptr b -> Word -> IO ()) -> IO (Maybe (Compact a)) Source #

Deserialize a SerializedCompact into a in-memory Compact. The provided function will be called with the address and size of each newly allocated block in succession, and should fill the memory from the external source (eg. by reading from a socket or from disk) importCompact can return Nothing if the Compact was corrupt or it had pointers that could not be adjusted.