Skip to main content

BinderKind

Enum BinderKind 

Source
pub enum BinderKind {
    Explicit,
    Implicit,
    StrictImplicit,
    Instance,
}
Expand description

How a parameter is SUPPLIED at a call site – Lean’s four binder kinds.

The kernel has exactly one Pi, so a binder kind is not a typing distinction: {A : Type} -> A and (A : Type) -> A and ⦃A : Type⦄ -> A denote the same type and the same terms inhabit it. What differs is what the ELABORATOR does at an application, and that is why the kind must travel out of the parser beside the term rather than inside it.

Variants§

§

Explicit

(x : T) – the caller writes the argument.

§

Implicit

{x : T} – inserted eagerly, solved by unification.

§

StrictImplicit

⦃x : T⦄ (Lean’s strict-implicit brackets) – inserted only when a LATER explicit argument is actually supplied, so an unapplied nilOf stays the polymorphic function rather than becoming an application with an unsolvable metavariable in it.

§

Instance

[C x] – resolved from the instance database, after the explicit arguments have pinned the class’s type variables.

Implementations§

Source§

impl BinderKind

Source

pub fn as_param_kind(self) -> ParamKind

The elaborator’s ParamKind for this binder – now a BIJECTION, one variant each.

★ THE LOSSY STEP IS GONE, AND THIS WAS THE ONE LINE. ParamKind had three variants and this enum four, so a strict implicit could only be collapsed onto Implicit. The collapse was made HERE, in one named function, rather than spelled at each hand-over site, against the day ParamKind grew its fourth variant. It has – Lean’s BinderInfo has exactly four constructors (Lean/Expr.lean:69) and ⦃⦄ earns its own because App.lean:726’s processStrictImplicitArg gives it a rule no other kind has: insert only if (← hasArgsToProcess), otherwise finalize. ParamKind::StrictImplicit now exists and elaborate_app_against implements precisely that rule, so ⦃α⦄ reaches the elaborator as itself and this function is a BIJECTION with no information left to lose. lean_conformance_t05_elaboration::a_strict_implicit_is_not_instantiated_until_an_explicit_argument_follows is what pins the behaviour end to end.

The legacy implicit_count model still STOPS at a strict implicit (count_implicits): a count can only describe an unconditional prefix, and over-inserting there emits a metavariable nothing can solve.

Source

pub fn of_param_kind(kind: ParamKind) -> BinderKind

The binder kind for an elaborator ParamKind – the inverse of as_param_kind.

Trait Implementations§

Source§

impl Clone for BinderKind

Source§

fn clone(&self) -> BinderKind

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 BinderKind

Source§

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

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

impl Hash for BinderKind

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 PartialEq for BinderKind

Source§

fn eq(&self, other: &BinderKind) -> 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 Copy for BinderKind

Source§

impl Eq for BinderKind

Source§

impl StructuralPartialEq for BinderKind

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.