acid-state-0.16.1.3: Add ACID guarantees to any serializable Haskell data structure.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Acid.Archive

Synopsis

- type Entry = ByteString
- data Entries
  - = Done
  - | Next Entry Entries
  - | Fail String
- putEntries :: [Entry] -> Builder
- packEntries :: [Entry] -> ByteString
- readEntries :: ByteString -> Entries
- entriesToList :: Entries -> [Entry]
- entriesToListNoFail :: Entries -> [Entry]
- data Archiver = Archiver {
  - archiveWrite :: [Entry] -> ByteString
  - archiveRead :: ByteString -> Entries
  }
- defaultArchiver :: Archiver

# Documentation

type Entry = ByteString Source #

A bytestring that represents an entry in an archive.

data Entries Source #

Result of unpacking an archive. This is essentially a list of `Entry`, but may terminate in `Fail` if the archive format is incorrect.

Constructors

Done |
Next Entry Entries |
Fail String |

#### Instances

Instances details

Show Entries Source # |
Instance details Defined in Data.Acid.Archive Methods showsPrec :: Int -> Entries -> ShowS Source # show :: Entries -> String Source # showList :: [Entries] -> ShowS Source #

putEntries :: [Entry] -> Builder Source #

packEntries :: [Entry] -> ByteString Source #

readEntries :: ByteString -> Entries Source #

entriesToList :: Entries -> [Entry] Source #

Convert `Entries` to a normal list, calling `error` if there was a failure in unpacking the archive.

entriesToListNoFail :: Entries -> [Entry] Source #

Convert `Entries` to a normal list, silently ignoring a failure to unpack the archive and instead returning a truncated list.

data Archiver Source #

Interface for the lowest level of the serialisation layer, which handles packing lists of `Entry` elements (essentially just bytestrings) into a single bytestring, perhaps with error-checking.

Any ``Archiver`{`archiveWrite`, `archiveRead`}` must satisfy the round-trip property:

    forall xs . entriesToList (archiveRead (archiveWrite xs)) == xs

Moreover, `archiveWrite` must be a monoid homomorphism, so that concatenating archives is equivalent to concatenating the lists of entries that they represent:

    archiveWrite [] == empty
    forall xs ys . archiveWrite xs <> archiveWrite ys == archiveWrite (xs ++ ys)

Constructors

Archiver |

Fields

- archiveWrite :: [Entry] -> ByteString

  Pack a list of entries into a bytestring.

- archiveRead :: ByteString -> Entries

  Unpack a bytestring as a list of `Entries`, including the possibility of failure if the format is invalid.

defaultArchiver :: Archiver Source #

Standard (and historically the only) implementation of the `Archiver` interface. This represents each entry in the following format:

    | entry length | crc16   | entry   |
    | 8 bytes      | 2 bytes | n bytes |