hugr_model::v0

Enum Term

Source
pub enum Term<'a> {
Show 21 variants Wildcard, Type, StaticType, Constraint, Var(LocalRef<'a>), Apply { global: GlobalRef<'a>, args: &'a [TermId], }, ApplyFull { global: GlobalRef<'a>, args: &'a [TermId], }, Quote { type: TermId, }, List { parts: &'a [ListPart], }, ListType { item_type: TermId, }, Str(&'a str), StrType, Nat(u64), NatType, ExtSet { parts: &'a [ExtSetPart<'a>], }, ExtSetType, Adt { variants: TermId, }, FuncType { inputs: TermId, outputs: TermId, extensions: TermId, }, Control { values: TermId, }, ControlType, NonLinearConstraint { term: TermId, },
}
Expand description

A term in the compile time meta language.

Variants§

§

Wildcard

Standin for any term.

§

Type

The type of runtime types.

type : static

§

StaticType

The type of static types.

static : static

§

Constraint

The type of constraints.

constraint : static

§

Var(LocalRef<'a>)

A local variable.

§

Apply

A symbolic function application.

The arguments of this application cover only the explicit parameters of the referenced declaration, leaving out the implicit parameters. Once the type of the declaration is known, the implicit parameters can be inferred and the term replaced with Term::ApplyFull.

(GLOBAL ARG-0 ... ARG-n)

Fields

§global: GlobalRef<'a>

Reference to the global declaration to apply.

§args: &'a [TermId]

Arguments to the function, covering only the explicit parameters.

§

ApplyFull

A symbolic function application with all arguments applied.

The arguments to this application cover both the implicit and explicit parameters of the referenced declaration. Since this can be tedious to write out, only the explicit parameters can be provided via Term::Apply.

(@GLOBAL ARG-0 ... ARG-n)

Fields

§global: GlobalRef<'a>

Reference to the global declaration to apply.

§args: &'a [TermId]

Arguments to the function, covering both implicit and explicit parameters.

§

Quote

Quote a runtime type as a static type.

(quote T) : static where T : type.

Fields

§type: TermId

The runtime type to be quoted.

Type: type

§

List

A list. May include individual items or other lists to be spliced in.

Fields

§parts: &'a [ListPart]

The parts of the list.

§

ListType

The type of lists, given a type for the items.

(list T) : static where T : static.

Fields

§item_type: TermId

The type of the items in the list.

item_type : static

§

Str(&'a str)

A literal string.

"STRING" : str

§

StrType

The type of literal strings.

str : static

§

Nat(u64)

A literal natural number.

N : nat

§

NatType

The type of literal natural numbers.

nat : static

§

ExtSet

Extension set.

Fields

§parts: &'a [ExtSetPart<'a>]

The parts of the extension set.

Since extension sets are unordered, the parts may occur in any order.

§

ExtSetType

The type of extension sets.

ext-set : static

§

Adt

An algebraic data type.

(adt VARIANTS) : type where VARIANTS : (list (list type)).

Fields

§variants: TermId

List of variants in the algrebaic data type. Each of the variants is itself a list of runtime types.

§

FuncType

The type of functions, given lists of input and output types and an extension set.

Fields

§inputs: TermId

The input types of the function, given as a list of runtime types.

inputs : (list type)

§outputs: TermId

The output types of the function, given as a list of runtime types.

outputs : (list type)

§extensions: TermId

The set of extensions that the function requires to be present in order to be called.

extensions : ext-set

§

Control

Control flow.

(ctrl VALUES) : ctrl where VALUES : (list type).

Fields

§values: TermId

List of values.

§

ControlType

Type of control flow edges.

ctrl : static

§

NonLinearConstraint

Constraint that requires a runtime type to be copyable and discardable.

Fields

§term: TermId

The runtime type that must be copyable and discardable.

Trait Implementations§

Source§

impl<'a> Clone for Term<'a>

Source§

fn clone(&self) -> Term<'a>

Returns a copy 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<'a> Debug for Term<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Term<'a>

Source§

fn default() -> Term<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> Hash for Term<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for Term<'a>

Source§

fn eq(&self, other: &Term<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Term<'a>

Source§

impl<'a> StructuralPartialEq for Term<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Term<'a>

§

impl<'a> RefUnwindSafe for Term<'a>

§

impl<'a> Send for Term<'a>

§

impl<'a> Sync for Term<'a>

§

impl<'a> Unpin for Term<'a>

§

impl<'a> UnwindSafe for Term<'a>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.