LambdaLanguageOfThought

Trait LambdaLanguageOfThought 

Source
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§

Source

type Pool

The type of the executable syntax tree

Source

type ConversionError

Required Methods§

Source

fn get_children(&self) -> impl Iterator<Item = LambdaExprRef>

Given an expression, get an iterator of its children

Source

fn remap_refs(&mut self, remap: &[usize])

Update the references such that LambdaExprRef(0) is remapped to LambdaExprRef(remap[0]). (Used in garbage collection).

Source

fn inc_depth(&self) -> bool

Returns true if this is somewhere that can bind variables (e.g. should we increment debruijn indices

Source

fn var_type(&self) -> Option<&LambdaType>

Returns the type of the bound variable at an instruction

Source

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.

Source

fn n_children(&self) -> usize

Get the number of children of an expression.

Source

fn get_type(&self) -> &LambdaType

Get the return type of an expression.

Source

fn get_arguments(&self) -> impl Iterator<Item = LambdaType>

Get the type of all children in order.

Source

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.

Implementations on Foreign Types§

Source§

impl LambdaLanguageOfThought for ()

Implementors§

Source§

impl<'a> LambdaLanguageOfThought for Expr<'a>

Source§

type Pool = LanguageExpression<'a>

Source§

type ConversionError = LambdaConversionError