Packages for sequences of Data.Map
differences.
Below is a simple example of defining a sequence of differences using
root-measured finger trees and diffs. For more in-depth information about
root-measured finger trees and diffs, read the following two READMEs. It is
recommended to read them in order, because the documentation of fingertree-rm
will justify choices and goals for diff-containers
.
import qualified Data.Map.Diff.Strict as Diff
import qualified Data.FingerTree.RootMeasured.Strict as FTRM
-- | A sequence of differences as a root-measured finger tree, storing the total
-- sum of diffs at the root, and the length of sub-sequences in each node of the
-- finger tree tree.
type DiffSeq k v = FTRM.StrictFingerTree (Diff k v) (Sum Int) (Diff k v)
instance RootMeasured (Diff k v) (Diff k v) where
measureRoot = id
instance Measured (Diff k v) (Sum Int) where
measure = const 1