ghc-compact-0.1.0.0: In memory storage of deeply evaluated data structure
Copyright(c) The University of Glasgow 2001-2009
(c) Giovanni Campagna <gcampagn@cs.stanford.edu> 2015
LicenseBSD-style (see the file LICENSE)
Maintainerlibraries@haskell.org
Stabilityunstable
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

GHC.Compact.Serialized

Description

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

Since: 1.0.0

Synopsis

Documentation

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 :: Compact a -> (SerializedCompact a -> IO c) -> IO c Source #

Serialize the Compact, and call the provided function with with the Compact serialized representation. It is not safe to return the pointer from the action and use it after the action completes: all uses must be inside this bracket, since we cannot guarantee that the compact region will stay live from the Ptr object. For example, it would be unsound to use unsafeInterleaveIO to lazily construct a lazy bytestring from the Ptr.

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.

importCompactByteStrings :: SerializedCompact a -> [ByteString] -> IO (Maybe (Compact a)) Source #

Convenience function for importing a compact region that is represented by a list of strict ByteStrings.