stable-tree-0.0.1: Trees whose branches are resistant to change

CopyrightJeremy Groven
LicenseBSD3
Safe HaskellNone
LanguageHaskell2010

Data.StableTree.IO

Description

Logic for dealing with the actual storage of Stable Trees. The key exports here are Error, Store, load, and store. A user needs to implement the loadTree, loadValue, storeTree and storeValue parts of Store, and make an appropriate Error type to report storage errors, and then the load and store functions can just do their thing. If necessary, a user can also implement Build for custom data types.

Synopsis

Documentation

data Store e k v Source

Write appropriate functions here to load and store primitive parts of trees.

Constructors

Store 

Fields

loadTree :: Id -> IO (Either e (Int, Map k Id))
 
loadValue :: Id -> IO (Either e v)
 
storeTree :: Id -> Int -> Map k Id -> IO (Maybe e)
 
storeValue :: Id -> v -> IO (Maybe e)
 

class Build t where Source

Typeclass to generate unique ByteStrings for StableTree keys and values. Used to generate the unique identities for values and branches.

Methods

build :: t -> Builder Source

class Error e where Source

Things go wrong with end-user storage, but things can also go wrong with reconstructing tree values. Implement stableTreeError to allow load and store to report their own errors.

Methods

stableTreeError :: Text -> e Source

Instances

data Id Source

The opaque type to identify values and branches of trees.

Instances

load :: (IsKey k, Ord k, Error e) => Store e k v -> Id -> IO (Either e (StableTree k v)) Source

Retrieve a tree given its id.

store :: (Build k, Ord k, Build v) => Store e k v -> StableTree k v -> IO (Either e Id) Source

Store a tree using a Store and return its calculated Id

buildBinary :: Binary t => t -> Builder Source

Generate a builder for something that is already a Binary

buildSerialize :: Serialize t => t -> Builder Source

Generate a builder for something that is already a Serialize