Struct formality_core::binder::CoreBinder
source · 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
.
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>
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).source§fn size(&self) -> usize
fn size(&self) -> usize
source§fn assert_valid(&self)
fn assert_valid(&self)
source§fn references_only_universal_variables(&self) -> bool
fn references_only_universal_variables(&self) -> bool
source§impl<L: Default + Language, T: Default> Default for CoreBinder<L, T>
impl<L: Default + Language, T: Default> Default for CoreBinder<L, T>
source§fn default() -> CoreBinder<L, T>
fn default() -> CoreBinder<L, T>
source§impl<L: Language, T, U> DowncastTo<CoreBinder<L, T>> for CoreBinder<L, U>where
T: DowncastFrom<U>,
impl<L: Language, T, U> DowncastTo<CoreBinder<L, T>> for CoreBinder<L, U>where
T: DowncastFrom<U>,
fn downcast_to(&self) -> Option<CoreBinder<L, T>>
source§impl<L: Ord + Language, T: Ord> Ord for CoreBinder<L, T>
impl<L: Ord + Language, T: Ord> Ord for CoreBinder<L, T>
source§fn cmp(&self, other: &CoreBinder<L, T>) -> Ordering
fn cmp(&self, other: &CoreBinder<L, T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<L: PartialEq + Language, T: PartialEq> PartialEq for CoreBinder<L, T>
impl<L: PartialEq + Language, T: PartialEq> PartialEq for CoreBinder<L, T>
source§fn eq(&self, other: &CoreBinder<L, T>) -> bool
fn eq(&self, other: &CoreBinder<L, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<L: PartialOrd + Language, T: PartialOrd> PartialOrd for CoreBinder<L, T>
impl<L: PartialOrd + Language, T: PartialOrd> PartialOrd for CoreBinder<L, T>
source§fn partial_cmp(&self, other: &CoreBinder<L, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &CoreBinder<L, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more