pub struct CoreBinder<L: Language, T> { /* private fields */ }
Implementations§
Source§impl<L: Language, T: CoreFold<L>> CoreBinder<L, T>
impl<L: Language, T: CoreFold<L>> CoreBinder<L, T>
Sourcepub fn open(&self) -> (Vec<CoreBoundVar<L>>, T)
pub fn open(&self) -> (Vec<CoreBoundVar<L>>, T)
Accesses the contents of the binder.
The variables inside will be renamed to fresh var indices that do not alias any other indices seen during this computation.
The expectation is that you will create a term and use Binder::new
.
pub fn dummy(term: T) -> Self
Sourcepub fn new(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self
pub fn new(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self
Given a set of variables (X, Y, Z) and a term referecing some subset of them, create a binder where exactly those variables are bound (even the ones not used).
Sourcepub fn mentioned(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self
pub fn mentioned(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self
Given a set of variables (X, Y, Z) and a term referecing some subset of them, create a binder for just those variables that are mentioned.
pub fn into<U>(self) -> CoreBinder<L, U>where
T: Into<U>,
pub fn is_empty(&self) -> bool
Sourcepub fn instantiate_with(
&self,
parameters: &[impl Upcast<CoreParameter<L>>],
) -> Fallible<T>
pub fn instantiate_with( &self, parameters: &[impl Upcast<CoreParameter<L>>], ) -> Fallible<T>
Instantiate the binder with the given parameters, returning an err if the parameters are the wrong number or ill-kinded.
Sourcepub fn instantiate(
&self,
op: impl FnMut(CoreKind<L>, VarIndex) -> CoreParameter<L>,
) -> T
pub fn instantiate( &self, op: impl FnMut(CoreKind<L>, VarIndex) -> CoreParameter<L>, ) -> T
Instantiate the term, replacing each bound variable with op(i)
.
Sourcepub fn peek(&self) -> &T
pub fn peek(&self) -> &T
Accesses the data inside the binder. Use this for simple tests that extract data
that is independent of the bound variables. If that’s not the case, use open
.
Sourcepub fn kinds(&self) -> &[CoreKind<L>] ⓘ
pub fn kinds(&self) -> &[CoreKind<L>] ⓘ
Returns the kinds of each variable bound by this binder
pub fn map<U: CoreFold<L>>(&self, op: impl FnOnce(T) -> U) -> CoreBinder<L, U>
Trait Implementations§
Source§impl<L: Clone + Language, T: Clone> Clone for CoreBinder<L, T>
impl<L: Clone + Language, T: Clone> Clone for CoreBinder<L, T>
Source§fn clone(&self) -> CoreBinder<L, T>
fn clone(&self) -> CoreBinder<L, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<L: Language, T: CoreFold<L>> CoreFold<L> for CoreBinder<L, T>
impl<L: Language, T: CoreFold<L>> CoreFold<L> for CoreBinder<L, T>
Source§fn substitute(&self, substitution_fn: SubstitutionFn<'_, L>) -> Self
fn substitute(&self, substitution_fn: SubstitutionFn<'_, L>) -> Self
Source§fn shift_in(&self) -> Self
fn shift_in(&self) -> Self
Source§fn replace_free_var(
&self,
v: impl Upcast<CoreVariable<L>>,
p: impl Upcast<CoreParameter<L>>,
) -> Self
fn replace_free_var( &self, v: impl Upcast<CoreVariable<L>>, p: impl Upcast<CoreParameter<L>>, ) -> Self
v
with p
.Source§impl<L, T> CoreParse<L> for CoreBinder<L, T>
Parse a binder: find the names in scope, parse the contents, and then
replace names with debruijn indices.
impl<L, T> CoreParse<L> for CoreBinder<L, T>
Parse a binder: find the names in scope, parse the contents, and then replace names with debruijn indices.
Source§fn parse<'t>(scope: &Scope<L>, text: &'t str) -> ParseResult<'t, Self>
fn parse<'t>(scope: &Scope<L>, text: &'t str) -> ParseResult<'t, Self>
Source§fn parse_many<'t>(
scope: &Scope<L>,
text: &'t str,
close_char: char,
) -> ParseResult<'t, Vec<Self>>
fn parse_many<'t>( scope: &Scope<L>, text: &'t str, close_char: char, ) -> ParseResult<'t, Vec<Self>>
close_char
to appear after the last instance
(close_char
is not consumed).Source§fn parse_comma<'t>(
scope: &Scope<L>,
text: &'t str,
close_char: char,
) -> ParseResult<'t, Vec<Self>>
fn parse_comma<'t>( scope: &Scope<L>, text: &'t str, close_char: char, ) -> ParseResult<'t, Vec<Self>>
Source§impl<L: Language, T: CoreVisit<L>> CoreVisit<L> for CoreBinder<L, T>
impl<L: Language, T: CoreVisit<L>> CoreVisit<L> for CoreBinder<L, T>
Source§fn free_variables(&self) -> Vec<CoreVariable<L>>
fn free_variables(&self) -> Vec<CoreVariable<L>>
Variable::is_free
).
The list may contain duplicates and must be in a determinstic order (though the order itself isn’t important).