Skip to main content

RecursorBuilder

Struct RecursorBuilder 

Source
pub struct RecursorBuilder {
    pub name: Name,
    pub univ_params: Vec<Name>,
    pub num_params: u32,
    pub num_indices: u32,
    pub num_motives: u32,
    pub num_minor_premises: u32,
    pub rules: Vec<RecursorRule>,
    pub is_prop: bool,
}
Expand description

A builder for constructing recursor definitions programmatically.

Recursors (eliminators) are the fundamental way to consume inductive types. This builder provides a fluent API for constructing them.

Fields§

§name: Name

Name of the recursor (typically T.rec or T.recOn).

§univ_params: Vec<Name>

Universe parameters.

§num_params: u32

Number of type parameters.

§num_indices: u32

Number of indices.

§num_motives: u32

Number of motives (typically 1).

§num_minor_premises: u32

Number of minor premises (one per constructor).

§rules: Vec<RecursorRule>

Recursor rules (one per constructor).

§is_prop: bool

Whether the recursor targets Prop.

Implementations§

Source§

impl RecursorBuilder

Source

pub fn new(name: Name) -> Self

Create a new builder.

Source

pub fn univ_params(self, params: Vec<Name>) -> Self

Set universe parameters.

Source

pub fn num_params(self, n: u32) -> Self

Set the number of parameters.

Source

pub fn num_indices(self, n: u32) -> Self

Set the number of indices.

Source

pub fn is_prop(self, b: bool) -> Self

Set whether the recursor targets Prop.

Source

pub fn add_rule(self, rule: RecursorRule) -> Self

Add a recursor rule.

Source

pub fn validate(&self) -> Result<(), String>

Validate the builder state.

Returns Ok(()) if the builder is consistent.

Source

pub fn build_name(&self) -> Name

Return the name of the recursor.

Source

pub fn build(&self, ty: Expr, all: Vec<Name>) -> Result<RecursorVal, String>

Build a complete RecursorVal from the builder state.

ty is the type of the recursor (must be supplied by the caller since this builder does not reconstruct the Pi telescope). all is the list of inductive type names in the mutual family.

Trait Implementations§

Source§

impl Clone for RecursorBuilder

Source§

fn clone(&self) -> RecursorBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecursorBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.