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
impl BinderKind
Sourcepub fn as_param_kind(self) -> ParamKind
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.
Sourcepub fn of_param_kind(kind: ParamKind) -> BinderKind
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
impl Clone for BinderKind
Source§fn clone(&self) -> BinderKind
fn clone(&self) -> BinderKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BinderKind
impl Debug for BinderKind
Source§impl Hash for BinderKind
impl Hash for BinderKind
Source§impl PartialEq for BinderKind
impl PartialEq for BinderKind
impl Copy for BinderKind
impl Eq for BinderKind
impl StructuralPartialEq for BinderKind
Auto Trait Implementations§
impl Freeze for BinderKind
impl RefUnwindSafe for BinderKind
impl Send for BinderKind
impl Sync for BinderKind
impl Unpin for BinderKind
impl UnsafeUnpin for BinderKind
impl UnwindSafe for BinderKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.