| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Pattern.PatternGraph
Description
backed by Pattern v, with merge-on-insert semantics.
Unrecognized patterns are routed to pgOther by the GraphClassifier.
Patterns that fail reconciliation are preserved in pgConflicts.
See specs033-pattern-graph for design and data model.
Round-trip with gram: parse (e.g. fromGram) → fromPatterns → modify
(e.g. merge) → serialize by flattening pgNodes, pgRelationships, pgWalks,
pgAnnotations and calling toGram. See quickstart.md and
libsgramtestsSpecGram/RoundtripSpec.hs (PatternGraph round-trip test).
Synopsis
- data PatternGraph extra v = PatternGraph {}
- class Ord (Id v) => GraphValue v where
- merge :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> Pattern v -> PatternGraph extra v -> PatternGraph extra v
- mergeWithPolicy :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> Pattern v -> PatternGraph extra v -> PatternGraph extra v
- fromPatterns :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> [Pattern v] -> PatternGraph extra v
- fromPatternsWithPolicy :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> [Pattern v] -> PatternGraph extra v
- empty :: GraphValue v => PatternGraph extra v
- fromPatternGraph :: (GraphValue v, Eq v) => PatternGraph extra v -> GraphQuery v
- toGraphView :: (GraphValue v, Eq v) => GraphClassifier extra v -> PatternGraph extra v -> GraphView extra v
- materialize :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> GraphView extra v -> PatternGraph extra v
Graph container
data PatternGraph extra v Source #
Container holding four categories of graph elements, each keyed by identity.
All stored elements are 'Pattern v'; classification is via GraphValue.
Constructors
| PatternGraph | |
Instances
| (Show (Id v), Show v, Show extra) => Show (PatternGraph extra v) Source # | |
Defined in Pattern.PatternGraph Methods showsPrec :: Int -> PatternGraph extra v -> ShowS # show :: PatternGraph extra v -> String # showList :: [PatternGraph extra v] -> ShowS # | |
| (Eq (Id v), Eq v, Eq extra) => Eq (PatternGraph extra v) Source # | |
Defined in Pattern.PatternGraph Methods (==) :: PatternGraph extra v -> PatternGraph extra v -> Bool # (/=) :: PatternGraph extra v -> PatternGraph extra v -> Bool # | |
Classification
class Ord (Id v) => GraphValue v where Source #
Typeclass providing identity and classification for the value type v.
Used to classify patterns as NodeAnnotationRelationshipWalkUnrecognized.
Merge and construction
merge :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> Pattern v -> PatternGraph extra v -> PatternGraph extra v Source #
Merge a single pattern into the graph. Uses LastWriteWins for duplicate identities.
mergeWithPolicy :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> Pattern v -> PatternGraph extra v -> PatternGraph extra v Source #
Merge a single pattern using the given reconciliation policy for duplicate identities.
fromPatterns :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> [Pattern v] -> PatternGraph extra v Source #
Build a graph from a list of patterns (fold of merge).
fromPatternsWithPolicy :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> [Pattern v] -> PatternGraph extra v Source #
Build a graph from a list of patterns using the given reconciliation policy.
empty :: GraphValue v => PatternGraph extra v Source #
Empty graph (all five maps empty).
Conversion to GraphQuery
fromPatternGraph :: (GraphValue v, Eq v) => PatternGraph extra v -> GraphQuery v Source #
Construct a 'GraphQuery v' directly from a 'PatternGraph extra v'.
Reads from the typed maps (pgNodes, pgRelationships, pgWalks,
pgAnnotations) without going through GraphLens. Provides O(log n)
lookups for queryNodeById and queryRelationshipById.
Preferred over constructing a GraphLens for algorithm access.
GraphView construction and materialization
toGraphView :: (GraphValue v, Eq v) => GraphClassifier extra v -> PatternGraph extra v -> GraphView extra v Source #
Construct a GraphView from a PatternGraph.
The GraphClassifier determines the GraphClass tag for each element.
viewQuery is the snapshot query built from the same graph; it is never
updated by subsequent transformations, ensuring deterministic context-aware
operations.
Note: defined here (not in Pattern.Graph) to avoid a circular import —
Graph cannot import PatternGraph.
materialize :: (GraphValue v, Eq v, Mergeable v, HasIdentity v (Id v), Refinable v) => GraphClassifier extra v -> ReconciliationPolicy (MergeStrategy v) -> GraphView extra v -> PatternGraph extra v Source #
Reconstruct a PatternGraph from a GraphView.
Folds all elements in viewElements through mergeWithPolicy, using the
provided classifier and reconciliation policy. This is the finalizer for a
lazy transformation pipeline.
Note: defined here (not in Pattern.Graph) to avoid a circular import.