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

CopyrightJeremy Groven
LicenseBSD3
Safe HaskellNone
LanguageHaskell2010

Data.StableTree.Conversion

Description

Functions for converting between Tree and Fragment types

Synopsis

Documentation

toFragments :: Ord k => StableTree k v -> [(ObjectID, Fragment k v)] Source

Convert a StableTree Tree into a list of storable Fragments. The resulting list is guaranteed to be in an order where each Fragment will be seen after all its children.

fromFragments :: (Ord k, Serialize k, Serialize v) => Map ObjectID (Fragment k v) -> Fragment k v -> Either Text (StableTree k v) Source

Recover a Tree from a single Fragment and a map of the fragments as returned from toFragments. If the fragment set was already stored, it is the caller's responsibility to load all the child fragments into a map (probably involving finding children using the fragmentChildren field of the Fragment type).

fragsToMap :: Ord k => Map ObjectID (Fragment k v) -> Fragment k v -> Either Text (Map k v) Source

Directly convert a bunch of Fragments and a root fragment into a Map instance. Mostly useful for testing the correctness of the fromFragments function.