Portability | ghc |
---|---|
Stability | beta |
Maintainer | Neil Sculthorpe <neil@ittc.ku.edu> |
Safe Haskell | Safe-Inferred |
This module provides combinators to find LocalPath
s sub-nodes specified by a predicate.
- type WithLocalPath c crumb = ExtendContext c (LocalPath crumb)
- withLocalPathT :: Transform (WithLocalPath c crumb) m a b -> Transform c m a b
- exposeLocalPathT :: Monad m => Transform (WithLocalPath c crumb) m a (LocalPath crumb)
- acceptLocalPathT :: Monad m => Transform c m g Bool -> Transform (WithLocalPath c crumb) m g (LocalPath crumb)
- pathsToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g [LocalPath crumb]
- onePathToT :: forall c crumb g m. (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)
- oneNonEmptyPathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)
- prunePathsToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g [LocalPath crumb]
- uniquePathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)
- uniquePrunePathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)
Finding Local Paths
Context Transformers
To find a LocalPath
to a node that satisfies a predicate, use
,
where withLocalPathT
(tt (acceptLocalPathT
q))q
is a transformation returning Bool
, and tt
is a traversal strategy, such as collectT
or onetdT
.
This will handle the tracking of the local path.
See the example pathfinders below.
type WithLocalPath c crumb = ExtendContext c (LocalPath crumb)Source
A context transformer that adds a LocalPath
(from the current node) to the context.
withLocalPathT :: Transform (WithLocalPath c crumb) m a b -> Transform c m a bSource
Apply a transformation that stores a LocalPath
in the context (starting at the current node).
exposeLocalPathT :: Monad m => Transform (WithLocalPath c crumb) m a (LocalPath crumb)Source
Extract the current LocalPath
from the context.
acceptLocalPathT :: Monad m => Transform c m g Bool -> Transform (WithLocalPath c crumb) m g (LocalPath crumb)Source
Return the current LocalPath
if the predicate transformation succeeds.
Example Pathfinders
pathsToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g [LocalPath crumb]Source
Find the LocalPath
s to every node that satisfies the predicate.
onePathToT :: forall c crumb g m. (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)Source
Find the LocalPath
to the first node that satisfies the predicate (in a pre-order traversal).
oneNonEmptyPathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)Source
Find the LocalPath
to the first descendent node that satisfies the predicate (in a pre-order traversal).
prunePathsToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g [LocalPath crumb]Source
Find the LocalPath
s to every node that satisfies the predicate, ignoring nodes below successes.
uniquePathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)Source
Find the LocalPath
to the node that satisfies the predicate, failing if that does not uniquely identify a node.
uniquePrunePathToT :: (Walker (WithLocalPath c crumb) g, MonadCatch m) => Transform c m g Bool -> Transform c m g (LocalPath crumb)Source
Build a LocalPath
to the node that satisfies the predicate, failing if that does not uniquely identify a node (ignoring nodes below successes).