-
Notifications
You must be signed in to change notification settings - Fork 0
Navigation
Navigation is how you get around the abstract syntax tree. Navigation is the analog of changing directory at a unix prompt. Related to lenses. Mutter Mutter.
Type | Purpose |
---|---|
Crumb |
Single-level decent into the AST |
LocalPath |
Opaque list of Crumbs; a path from where you are |
GlobalPath |
Opaque list of Crumbs; a path from the root |
Considerable |
Language constructs that can be zoomed to |
Crumb
, LocalPath
, and GlobalPath
are all concepts from KURE. The specifics of Crumb
, and Considerable
, are from HERMIT.
appFun :: Crumb
sendCrumb :: Crumb -> Shell () -- TODO: rename as followCrumb.
Example:
sendCrumb appFun
Concepts:
-- HERMIT (@@) :: Context -> Crumb -> Context
LocalPath
is a list of Crumb
s. Like a path in unix, it can contain nonsense.
Considerable
is a context-specific mechanism for generating a LocalPath
.
We already have combinators for getting into a context, and staying there
pathR :: [Crumb] -> Rewrite a -> Rewrite a
pathRs :: [Crumb] -> [Rewrite a] -> Rewrite a
pathS :: [Crumb] -> Shell () -> Shell ()
We also have raw scoping
scope :: Shell () -> Shell ()
Two combinators, scope and follow.
scope :: Path p => p -> m a -> m a -- scoping with path
go :: Path p => p -> Shell () -- an effect
look :: Shell [Crumb] -- where can you go?
getPath :: Crumb -> Transform c LocalPath -- Access a path
scope_ = scope ()
instance Path ()
instance Path Crumb
instance Path LocalPath
instance Path [Crumb]
instance Path (Transformation c LocalPath)
instance Path (more complex things) -- TODO
Design:
rhsOf :: Name -> Shell ()
scope (rhsOf "x") $ do
....
Is we allow instance Path (Shell ())
this would work.
Alt Design:
rhsOf :: Name -> Transformation c LocalPath
And we do not support rhsOf
at the shell level, without using:
go $ rhsOf "x"
OR
goto $ rhsOf "x"