kure-2.18.6: Combinators for Strategic Programming
Copyright(c) 2012--2021 The University of Kansas
LicenseBSD3
MaintainerNeil Sculthorpe <neil.sculthorpe@ntu.ac.uk>
Stabilitybeta
Portabilityghc
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.KURE.Pathfinder

Description

This module provides combinators to find LocalPaths sub-nodes specified by a predicate.

Synopsis

Finding Local Paths

Context Transformers

To find a LocalPath to a node that satisfies a predicate, use withLocalPathT (tt (acceptLocalPathT q)), where 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 b Source #

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 :: MonadFail m => Transform c m u Bool -> Transform (WithLocalPath c crumb) m u (LocalPath crumb) Source #

Return the current LocalPath if the predicate transformation succeeds.

Example Pathfinders

pathsToT :: (Walker (WithLocalPath c crumb) u, MonadCatch m) => Transform c m u Bool -> Transform c m u [LocalPath crumb] Source #

Find the LocalPaths to every node that satisfies the predicate.

onePathToT :: forall c crumb u m. (Walker (WithLocalPath c crumb) u, MonadCatch m) => Transform c m u Bool -> Transform c m u (LocalPath crumb) Source #

Find the LocalPath to the first node that satisfies the predicate (in a pre-order traversal).

oneNonEmptyPathToT :: (Walker (WithLocalPath c crumb) u, MonadCatch m) => Transform c m u Bool -> Transform c m u (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) u, MonadCatch m) => Transform c m u Bool -> Transform c m u [LocalPath crumb] Source #

Find the LocalPaths to every node that satisfies the predicate, ignoring nodes below successes.

uniquePathToT :: (Walker (WithLocalPath c crumb) u, MonadCatch m) => Transform c m u Bool -> Transform c m u (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) u, MonadCatch m) => Transform c m u Bool -> Transform c m u (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).