Safe Haskell | None |
---|
Patterns allow monadic scrutinisation of the graph (modifications are not possible) while keeping track of matched nodes (history). 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]
- branch :: [a] -> Pattern n a
- visit :: Node -> Pattern n ()
- branchNodes :: [Node] -> Pattern n Node
- probe :: Pattern n a -> Pattern n Bool
- matches :: Pattern n a -> Pattern n [Match]
- match :: Pattern n a -> Pattern n [(Match, a)]
- (<|>) :: Pattern n a -> Pattern n a -> Pattern n a
- anyOf :: [Pattern n a] -> Pattern n a
- require :: Monad m => Bool -> m ()
- requireFailure :: Pattern n a -> Pattern n ()
- 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
- amnesia :: Pattern n a -> Pattern n a
- 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
probe :: Pattern n a -> Pattern n BoolSource
Probe whether a pattern matches somewhere on the graph. You might want to combine this with amnesia
.
matches :: Pattern n a -> Pattern n [Match]Source
probe a pattern returning the matches it has on the graph. You might want to combine this with amnesia
.
match :: Pattern n a -> Pattern n [(Match, a)]Source
probe a pattern returning the matches it has on the graph. You might want to combine this with amnesia
.
requireFailure :: Pattern n a -> Pattern n ()Source
fail
if given pattern succeeds, succeed if it fails.
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
amnesia :: Pattern n a -> Pattern n aSource
Do not remember any of the nodes matched by the supplied pattern
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 pattern that have not been matched before
restrictOverlap :: (Match -> Match -> Bool) -> Pattern n a -> Pattern n aSource
First match is the history with the most recently matched node in head position. Second match is the future with the next matched node in head position.
A pattern represents a graph scrutinisation that memorises all the scrutinised nodes during matching.