columbia-0.1.3: Enhanced serialization for media that support seeking.

Safe HaskellTrustworthy
LanguageHaskell98

Data.Columbia.Utils

Description

Some utility functions. The reader strategies maintain the invariant that the stream is seeked to the beginning of a data entity, so that it is safe to use 'readData'/'writeData'/'seekTo' etc. The writer strategies maintain the invariant that the writer is seeked at the word that should receive the address of the data entity that is written. This allows the writer to write eagerly the address and so be tail recursive in some cases.

Think of a columbia file as just a transactional log that is continually being written to; transactions are able to reference other transactions by address, thus constructing data structures; a single address, called the root node address, at the beginning of the file determines the file's nominal mutable state. To keep the file from getting too large, it is garbage collected periodically; calls to the collector have to be programmed to happen manually at a time convenient for your application.

Please be aware that while you *can* write new addresses over old in the file, this is not compatible with the locking scheme, which is predicated on the assumption that all writing happens to the root block address and appending to the end of the file.

Synopsis

Documentation

readFileWrapper :: (MonadError e m, MonadIO m) => FilePath -> ReaderT (SeekableStream m Word8) m t -> m t Source #

A wrapper for reading Columbia files; the proc parameter is a reading operation. Use fixT to make the conversion between PolyTraverals and recursive reading operations. Typically set m parameter to IO.

writeFileWrapper :: (MonadError e m, MonadIO m) => FilePath -> ReaderT (SeekableWriter m Word8) m t -> m t Source #

A wrapper for writing Columbia files; fixTW converts between PolyTraversalWs and recursive writing operations.