Open andygill opened 9 years ago
The old shell has a foralls-body
for this. Though in the new shell you can probably just use the underlying KURE combinator that applies a crumb to exhaustion:
forallsBodyT = extractT (exhaustRepeatCrumbT Forall_Body)
I've started a page about navigation.
I agree with all of Drew's remarks on this topic. A few further comments:
KURE provides the synonym:
type Path crumb = [crumb]
I would suggest using that where possible (e.g. pathR
) to distinguish from non-path lists of Crumbs (e.g. look
).
Crumbs are distinct atomic values that uniquely identify a child node. This should not be changed. If you want a concept that is more general than this, or you want to simplify the API so that users don't have to consider both crumbs and paths, you could just expose paths, and use singleton paths in place of crumbs. I haven't looked at hermit-shell, so I'm not sure whether you want Path
or LocalPath
(the latter is a snoc list).
There is no such thing as an upwards (or sidewards) crumb or path. This is inherent to the design of KURE, where only the current subtree can be transformed.
In KURE, one can construct a Lens
from a crumb or Path
using the following:
childL :: (ReadPath c crumb, Eq crumb, MonadCatch m) => crumb -> Lens c m u u
pathL :: (ReadPath c crumb, Eq crumb, Walker c u, MonadCatch m) => Path crumb -> Lens c m u u
In practice, I think we generally found it easier to work with Paths than Lenses. E.g. it is impossible to build an upwards lens, but one can navigate a LocalPath upwards by just deleting a suffix of the path. I think HERMIT just creates the Lens from the Path immediately prior to applying a transformation.
Thanks Neil. This is useful.
In one of our examples (new_reverse) we do
We want a way of saying jump through all the forallBody, like repeat (sendCrumb forallBody)