Trait libunseemly::walk_mode::WalkMode[][src]

pub trait WalkMode: Debug + Copy + Clone + Reifiable {
    type Elt: Clone + Debug + Reifiable + WalkElt;
    type Err: Debug + Reifiable + Clone;
    type D: Dir<Mode = Self>;
    type Negated: WalkMode<Elt = Self::Elt, Err = Self::Err, ExtraInfo = Self::ExtraInfo, Negated = Self>;
    type AsPositive: WalkMode<Elt = Self::Elt, Err = Self::Err, ExtraInfo = Self::ExtraInfo, D = Positive<Self::AsPositive>>;
    type AsNegative: NegativeWalkMode + WalkMode<Elt = Self::Elt, Err = Self::Err, ExtraInfo = Self::ExtraInfo, D = Negative<Self::AsNegative>>;
    type ExtraInfo: Default + Reifiable + Clone + Debug;
Show 13 methods fn get_walk_rule(form: &Form) -> WalkRule<Self>
    where
        Self: Sized
;
fn automatically_extend_env() -> bool;
fn name() -> &'static str; fn needs__splice_healing() -> bool { ... }
fn perform_splice_positive(
        _: &Form,
        _: &LazyWalkReses<Self>
    ) -> Result<Option<(Vec<Assoc<Name, Self::Elt>>, Ast)>, Self::Err> { ... }
fn perform_splice_negative(
        _: &Form,
        _: &LazyWalkReses<Self>,
        _context_elts: &dyn Fn() -> Vec<Ast>
    ) -> Result<Option<(Vec<Assoc<Name, Self::Elt>>, Ast)>, Self::Err> { ... }
fn walk_quasi_literally(
        expected: Ast,
        cnc: &LazyWalkReses<Self>
    ) -> Result<<<Self as WalkMode>::D as Dir>::Out, <Self as WalkMode>::Err> { ... }
fn out_as_elt(o: <Self::D as Dir>::Out) -> Self::Elt { ... }
fn out_as_env(o: <Self::D as Dir>::Out) -> Assoc<Name, Self::Elt> { ... }
fn env_as_out(e: Assoc<Name, Self::Elt>) -> <Self::D as Dir>::Out { ... }
fn walk_var(
        n: Name,
        cnc: &LazyWalkReses<Self>
    ) -> Result<<<Self as WalkMode>::D as Dir>::Out, <Self as WalkMode>::Err> { ... }
fn walk_atom(
        n: Name,
        cnc: &LazyWalkReses<Self>
    ) -> Result<<<Self as WalkMode>::D as Dir>::Out, <Self as WalkMode>::Err> { ... }
fn underspecified(_: Name) -> Self::Elt { ... }
}
Expand description

This trait exists to walk over Asts in different ways. get_walk_rule connects Forms to actual walk operations.

There are two kinds of walks over Asts:

  • Positive walks produce an element (a value or type, say) from an environment. They are for expression-like terms.
  • Negative walks produce an environment from an element. They are for pattern-like terms.

Now, the whole environment is actually present in both cases, and negative walks can actually use it – the special value they traverse is stored in the environment with a special name – but they conceptually are mostly relying on the special value.

Associated Types

The object type for the environment to walk in.

The negated version of this walk

If this walk is positive, Self; otherwise Self::Negated

If this walk is positive, Self::Negated; otherwise Self

Any extra information the walk needs

Required methods

Should the walker extend the environment based on imports? Only QQ and Expand have this as false; it’s not 100% clear what’s special about them. (This evolved over time; it used to be false for Eval, because of lambda). It seems like the thing about those modes is (a) they don’t look at variables, so their environments are irrelevant, (b) SameAs switching to the negated mode and doing get_res doesn’t work. But what unites those two factors?

Provided methods

Do we ever need to treat certain forms as though they were repetitions?

A little like get_walk_rule always returning Custom for positive splicing

A little like get_walk_rule always returning Custom for negative splicing

Walk over the structure of a node, not its meaning. This could be because we’re inside a syntax-quote, or it could be that we are a form (like written-out types or a literal) that acts like a literal. Children are not necessarily walked quasiliterally – maybe they’re an interpolation of some kind – instead, the mode (=quotation depth) and form together decide what to do. If the walk is negative, the result might be MatchFailure

Make up a special Elt that is currently “underspecified”, but which can be “unified” with some other Elt. If that happens, all copies of this Elt will act like that other one.

Side-effects under the covers make this work.

Implementors