dbvar-2021.8.23: Mutable variables that are written to disk using delta encodings.
Safe Haskell Safe-Inferred
Language Haskell2010

Data.Chain

Synopsis

Synopsis

Chain node edge is a linear chain of nodes with directed edges.

Chain

data Chain node edge Source #

A linear chain of nodes. Edges between nodes are labeled by a Monoid edge .

  n_tip  <--e_tip-- … <--e1-- n1 <--e0-- n0

Instances

Instances details
Functor ( Chain node) Source #
Instance details

Defined in Data.Chain

Methods

fmap :: (a -> b) -> Chain node a -> Chain node b Source #

(<$) :: a -> Chain node b -> Chain node a Source #

( Eq node, Eq edge) => Eq ( Chain node edge) Source #
Instance details

Defined in Data.Chain

Methods

(==) :: Chain node edge -> Chain node edge -> Bool Source #

(/=) :: Chain node edge -> Chain node edge -> Bool Source #

( Show node, Show edge) => Show ( Chain node edge) Source #
Instance details

Defined in Data.Chain

member :: Ord node => node -> Chain node edge -> Bool Source #

Test whether a node is contained in the chain.

type ChainContext node edge = Edge ( Maybe (edge, node)) node Source #

Context (incoming and outgoing edges) for a node in a Chain .

lookup :: Ord node => node -> Chain node edge -> Maybe ( ChainContext node edge) Source #

Look up the Context of a node in a Chain .

fromEdge :: Ord node => Edge node edge -> Chain node edge Source #

Construct a chain from a single Edge .

fromEdges :: Ord node => [ Edge node edge] -> Maybe ( Chain node [edge]) Source #

Construct a chain from a collection of edges. Fails if the edges do not fit together.

The ordering of edge labels of a single edge in the chain will be the same as the ordering of the edge labels as they appear in the list.

edges :: Ord node => Chain node edge -> [edge] Source #

List all edges in the Chain .

The edge that points to the tip is listed first , and the edge that starts at the beginning is listed last .

nodes :: Ord node => Chain node edge -> [node] Source #

List all nodes in the Chain . The tip is listed first .

toEdges :: Chain node edge -> [ Edge node edge] Source #

Convert a Chain into a list of Edge .

summary :: ( Ord node, Monoid edge) => Chain node edge -> edge Source #

Combine all the edges in the Chain . The summary is invariant under collapseNode .

summary = mconcat . edges

DeltaChain

data DeltaChain node edge Source #

Changes to a Chain .

Instances

Instances details
( Ord node, Semigroup edge) => Delta ( DeltaChain node edge) Source #
Instance details

Defined in Data.Chain

Associated Types

type Base ( DeltaChain node edge) Source #

Methods

apply :: DeltaChain node edge -> Base ( DeltaChain node edge) -> Base ( DeltaChain node edge) Source #

type Base ( DeltaChain node edge) Source #
Instance details

Defined in Data.Chain

type Base ( DeltaChain node edge) = Chain node edge

appendTip :: Ord node => node -> edge -> Chain node edge -> Chain node edge Source #

Append a new tip to the chain.

collapseNode :: ( Ord node, Semigroup edge) => node -> Chain node edge -> Chain node edge Source #

Remove the given node and combine the incoming and outgoing edges. Do nothing if the node is at the tip, or at the bottom, or not in the chain at all.

rollbackTo :: Ord node => node -> Chain node edge -> Chain node edge Source #

Remove the tip and more nodes from the chain until the given node is the tip.

Do nothing if the node is not in the chain.

chainIntoTable :: ( Ord node, Semigroup edge) => (edge -> Pile e) -> ( Pile e -> edge) -> Embedding ( DeltaChain node edge) [ DeltaTable ( Edge node e)] Source #

Embed a Chain into a table of Edge .

The first and second argument specify how the edge labels are to be mapped to and from sets of table rows. Importantly, we may not assume that the table stores the rows in any particular order.

Edge

data Edge node edge Source #

Utility type that represents an Edge in a graph: it connects two node via an edge label.

Constructors

Edge

Fields

Instances

Instances details
Functor ( Edge node) Source #
Instance details

Defined in Data.Chain

Methods

fmap :: (a -> b) -> Edge node a -> Edge node b Source #

(<$) :: a -> Edge node b -> Edge node a Source #

( Eq node, Eq edge) => Eq ( Edge node edge) Source #
Instance details

Defined in Data.Chain

Methods

(==) :: Edge node edge -> Edge node edge -> Bool Source #

(/=) :: Edge node edge -> Edge node edge -> Bool Source #

( Ord node, Ord edge) => Ord ( Edge node edge) Source #
Instance details

Defined in Data.Chain

Methods

compare :: Edge node edge -> Edge node edge -> Ordering Source #

(<) :: Edge node edge -> Edge node edge -> Bool Source #

(<=) :: Edge node edge -> Edge node edge -> Bool Source #

(>) :: Edge node edge -> Edge node edge -> Bool Source #

(>=) :: Edge node edge -> Edge node edge -> Bool Source #

max :: Edge node edge -> Edge node edge -> Edge node edge Source #

min :: Edge node edge -> Edge node edge -> Edge node edge Source #

( Show node, Show edge) => Show ( Edge node edge) Source #
Instance details

Defined in Data.Chain

flattenEdge :: Edge node [edge] -> [ Edge node edge] Source #

Flatten a list of edges

Testing