Skip to content
Andy Gill edited this page Oct 5, 2015 · 12 revisions

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.

Data Types

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.

Crumb

appFun :: Crumb
sendCrumb :: Crumb -> Shell () -- TODO: rename as followCrumb.

Example:

sendCrumb appFun

Concepts:

-- HERMIT (@@) :: Context -> Crumb -> Context

LocalPath

LocalPath is a list of Crumbs. Like a path in unix, it can contain nonsense.

Considerable

Considerable is a context-specific mechanism for generating a LocalPath.

Scoping an Navigation

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 ()

Proposal for design

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"