Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Chain node edge
- member :: Ord node => node -> Chain node edge -> Bool
- type ChainContext node edge = Edge ( Maybe (edge, node)) node
- lookup :: Ord node => node -> Chain node edge -> Maybe ( ChainContext node edge)
- fromEdge :: Ord node => Edge node edge -> Chain node edge
- fromEdges :: Ord node => [ Edge node edge] -> Maybe ( Chain node [edge])
- edges :: Ord node => Chain node edge -> [edge]
- nodes :: Ord node => Chain node edge -> [node]
- toEdges :: Chain node edge -> [ Edge node edge]
- summary :: ( Ord node, Monoid edge) => Chain node edge -> edge
-
data
DeltaChain
node edge
- = AppendTip node edge
- | CollapseNode node
- | RollbackTo node
- appendTip :: Ord node => node -> edge -> Chain node edge -> Chain node edge
- collapseNode :: ( Ord node, Semigroup edge) => node -> Chain node edge -> Chain node edge
- rollbackTo :: Ord node => node -> Chain node edge -> Chain node edge
- chainIntoTable :: ( Ord node, Semigroup edge) => (edge -> Pile e) -> ( Pile e -> edge) -> Embedding ( DeltaChain node edge) [ DeltaTable ( Edge node e)]
- data ErrMalformedChainTable = ErrMalformedChainTable
- data Edge node edge = Edge { }
- flattenEdge :: Edge node [edge] -> [ Edge node edge]
- testChain :: ( Table ( Edge Int Char ), [[ DeltaDB Int ( Edge Int Char )]])
Synopsis
Chain
node edge
is a linear chain of nodes with directed
edges.
Chain
A linear chain of nodes.
Edges between nodes are labeled by a
Monoid
edge
.
n_tip <--e_tip-- … <--e1-- n1 <--e0-- n0
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
.
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
.
AppendTip node edge |
See
|
CollapseNode node |
See
|
RollbackTo node |
See
|
Instances
( Ord node, Semigroup edge) => Delta ( DeltaChain node edge) Source # | |
Defined in Data.Chain type Base ( DeltaChain node edge) Source # apply :: DeltaChain node edge -> Base ( DeltaChain node edge) -> Base ( DeltaChain node edge) Source # |
|
type Base ( DeltaChain node edge) Source # | |
Defined in Data.Chain |
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 #
data ErrMalformedChainTable Source #
Instances
Eq ErrMalformedChainTable Source # | |
Defined in Data.Chain |
|
Show ErrMalformedChainTable Source # | |
Defined in Data.Chain |
|
Exception ErrMalformedChainTable Source # | |
Defined in Data.Chain |
Edge
Utility type that represents an
Edge
in a graph:
it connects two
node
via an
edge
label.
Instances
Functor ( Edge node) Source # | |
( Eq node, Eq edge) => Eq ( Edge node edge) Source # | |
( Ord node, Ord edge) => Ord ( Edge node edge) Source # | |
Defined in Data.Chain 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 # | |
flattenEdge :: Edge node [edge] -> [ Edge node edge] Source #
Flatten a list of edges