Skip to main content

Instance

Struct Instance 

Source
pub struct Instance {
    pub class: QualName,
    pub head: Type,
    pub head_name: HeadName,
    pub context: Vec<Predicate>,
    pub members: Vec<Declaration>,
    pub unchecked: Vec<Unchecked>,
    pub rejected: bool,
    pub span: NodeSpan,
}
Expand description

One instance declaration of a module: which class, which type, what it needs of that type’s arguments, and a checked body for each member.

A derived instance is one of these like any other. The bindings it was checked with are the ones its class’s derivation stands for, generated by canonicalization, and nothing here says they were not written.

The types here and the types inside a member’s Declaration are each their own inference’s. The variables of head are the ones the instance’s context is over; a member’s declaration is solved on its own, so its type and its own context name variables of that solve, and the two are related by the member’s signature at the head and not by sharing variable numbers.

Fields§

§class: QualName

The class, named by the package and module that declared it.

§head: Type

The type the instance is for: a declared type applied to a distinct variable per parameter, a tuple of distinct variables, or () (the head rule).

§head_name: HeadName

The name at the front of head, which with the class identifies the instance: two instances of one class whose heads share it are one instance declared twice, and a use of a member is answered by the one that matches.

§context: Vec<Predicate>

What the instance needs of the head’s variables, in the order written.

§members: Vec<Declaration>

The bindings that checked, one for each member of the class, sorted by name. Each is a Declaration named for the member, whose context is the instance’s own.

§unchecked: Vec<Unchecked>

The bindings that did not check, accounted for as Module::unchecked accounts for a value, sorted by name.

§rejected: bool

Whether the instance’s own check failed: a superclass the instance cannot prove at its head. An error stands behind it, and a backend refuses it.

§span: NodeSpan

Where the head line was written, instance through where.

Trait Implementations§

Source§

impl Debug for Instance

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> 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, 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.