Copyright | Jeremy Groven |
---|---|
License | BSD3 |
Safe Haskell | None |
Language | Haskell2010 |
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.
- data Store e k v = Store {}
- class Build t where
- class Error e where
- stableTreeError :: Text -> e
- data Id
- load :: (IsKey k, Ord k, Error e) => Store e k v -> Id -> IO (Either e (StableTree k v))
- store :: (Build k, Ord k, Build v) => Store e k v -> StableTree k v -> IO (Either e Id)
- buildBinary :: Binary t => t -> Builder
- buildSerialize :: Serialize t => t -> Builder
Documentation
Write appropriate functions here to load and store primitive parts of trees.
Typeclass to generate unique ByteString
s for StableTree keys and values.
Used to generate the unique identities for values and branches.
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.
stableTreeError :: Text -> e Source
The opaque type to identify values and branches of trees.
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.
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