Patterns allow monadic scrutinisation of the graph (modifications are not possible) while keeping track of matched nodes. A Pattern
is interpreted by runPattern
that returns a result for each position in the graph where the pattern matches. It is allowed to fail
inside the Pattern
monad, indicating that the pattern does not match, which corresponds to conditional rewriting.
- runPattern :: Pattern n a -> Graph n -> [(Match, a)]
- evalPattern :: Pattern n a -> Graph n -> [a]
- execPattern :: Pattern n a -> Graph n -> [Match]
- matches :: Pattern n a -> Pattern n [Match]
- (<|>) :: Pattern n a -> Pattern n a -> Pattern n a
- anyOf :: [Pattern n a] -> Pattern n a
- require :: Monad m => Bool -> m ()
- requireM :: Monad m => m Bool -> m ()
- liftReader :: Reader (Graph n) a -> Pattern n a
- node :: View v n => Pattern n v
- previous :: Pattern n Node
- edge :: Pattern n Edge
- nodeAt :: View v n => Edge -> Pattern n v
- edgeOf :: View [Port] n => Node -> Pattern n Edge
- neighbour :: (View [Port] n, View v n) => Node -> Pattern n v
- relative :: (View [Port] n, View v n) => Node -> Pattern n v
- adverse :: (View [Port] n, View v n) => Port -> Node -> Pattern n v
- history :: Pattern n Match
- nextFresh :: Pattern n a -> Pattern n a
- nextIs :: Node -> Pattern n a -> Pattern n a
- restrictOverlap :: (Match -> Match -> Bool) -> Pattern n a -> Pattern n a
- linear :: Pattern n a -> Pattern n a
- data Pattern n a
- type Match = [Node]
Documentation
runPattern :: Pattern n a -> Graph n -> [(Match, a)]Source
Apply a pattern on a graph returning a result for each matching position in the graph together with the matched nodes.
evalPattern :: Pattern n a -> Graph n -> [a]Source
execPattern :: Pattern n a -> Graph n -> [Match]Source
matches :: Pattern n a -> Pattern n [Match]Source
probe a pattern returning the matches it has on the graph
liftReader :: Reader (Graph n) a -> Pattern n aSource
neighbour :: (View [Port] n, View v n) => Node -> Pattern n vSource
node that is connected to the given node, but not that node itself
relative :: (View [Port] n, View v n) => Node -> Pattern n vSource
node that is connected to the given node, permitting the node itself
adverse :: (View [Port] n, View v n) => Port -> Node -> Pattern n vSource
nodes connected to given port of the specified node, not including the node itself
history :: Pattern n MatchSource
list of nodes matched until now with the most recent node in head position
nextFresh :: Pattern n a -> Pattern n aSource
only match nodes in the next node pattern that have not been matched before