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 2015 BSD-style (see the file LICENSE) libraries@haskell.org unstable non-portable (GHC Extensions) Safe-Inferred Haskell2010

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

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).

Constructors

 SerializedCompact FieldsserializedCompactBlockList :: [(Ptr (), Word)] serializedCompactRoot :: Ptr ()

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.

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