pub trait LambdaLanguageOfThought {
type Pool;
type ConversionError;
// Required methods
fn get_children(&self) -> impl Iterator<Item = LambdaExprRef>;
fn remap_refs(&mut self, remap: &[usize]);
fn inc_depth(&self) -> bool;
fn var_type(&self) -> Option<&LambdaType>;
fn change_children(
&mut self,
new_children: impl Iterator<Item = LambdaExprRef>,
);
fn n_children(&self) -> usize;
fn get_type(&self) -> &LambdaType;
fn get_arguments(&self) -> impl Iterator<Item = LambdaType>;
fn to_pool(
pool: RootedLambdaPool<'_, Self>,
) -> Result<Self::Pool, Self::ConversionError>
where Self: Sized;
}Expand description
A trait which allows one to define a language of thought that interacts with the lambda
calculus. An example implementation can be found for crate::language::Expr.
Required Associated Types§
Sourcetype ConversionError
type ConversionError
Error for converting from RootedLambdaPool<T> to LambdaLanguageOfThought::Pool
Required Methods§
Sourcefn get_children(&self) -> impl Iterator<Item = LambdaExprRef>
fn get_children(&self) -> impl Iterator<Item = LambdaExprRef>
Given an expression, get an iterator of its children
Sourcefn remap_refs(&mut self, remap: &[usize])
fn remap_refs(&mut self, remap: &[usize])
Update the references such that LambdaExprRef(0) is remapped to LambdaExprRef(remap[0]).
(Used in garbage collection).
Sourcefn inc_depth(&self) -> bool
fn inc_depth(&self) -> bool
Returns true if this is somewhere that can bind variables (e.g. should we increment debruijn indices
Sourcefn var_type(&self) -> Option<&LambdaType>
fn var_type(&self) -> Option<&LambdaType>
Returns the type of the bound variable at an instruction
Sourcefn change_children(&mut self, new_children: impl Iterator<Item = LambdaExprRef>)
fn change_children(&mut self, new_children: impl Iterator<Item = LambdaExprRef>)
Given a list of new references for all children of an expr, change its children.
Sourcefn n_children(&self) -> usize
fn n_children(&self) -> usize
Get the number of children of an expression.
Sourcefn get_type(&self) -> &LambdaType
fn get_type(&self) -> &LambdaType
Get the return type of an expression.
Sourcefn get_arguments(&self) -> impl Iterator<Item = LambdaType>
fn get_arguments(&self) -> impl Iterator<Item = LambdaType>
Get the type of all children in order.
Sourcefn to_pool(
pool: RootedLambdaPool<'_, Self>,
) -> Result<Self::Pool, Self::ConversionError>where
Self: Sized,
fn to_pool(
pool: RootedLambdaPool<'_, Self>,
) -> Result<Self::Pool, Self::ConversionError>where
Self: Sized,
Convert from a RootedLambdaPool<T> to LambdaLanguageOfThought::Pool. May return an
error if there are any lambda terms left in the RootedLambdaPool<T> (e.g. not fully
reduced).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.