pub enum InferType {
Show 25 variants
Int,
Float,
Bool,
Char,
Byte,
String,
Unit,
Nat,
Rational,
Duration,
Date,
Moment,
Time,
Span,
Element,
Event,
View,
Seq(Box<InferType>),
Map(Box<InferType>, Box<InferType>),
Set(Box<InferType>),
Option(Box<InferType>),
UserDefined(Symbol, Vec<InferType>),
Var(TyVar),
Function(Vec<InferType>, Box<InferType>),
Unknown,
}Expand description
Inference-time type representation.
Extends LogosType with:
InferType::Var— an unbound type variableInferType::Function— a function type (not needed in codegen)InferType::Unknown— propagated uncertainty (unifies with anything)
Variants§
Int
Float
Bool
Char
Byte
String
Unit
Nat
Rational
Duration
Date
Moment
Time
Span
Element
A DOM element handle. Nominal: distinct from Int and from Event, even though
every tier represents it as an i64 handle at runtime.
Event
A DOM event handle (the argument of an event handler). Nominal, like Element.
View
A view value (a template with its captured bindings). Nominal.
Seq(Box<InferType>)
Map(Box<InferType>, Box<InferType>)
Set(Box<InferType>)
Option(Box<InferType>)
UserDefined(Symbol, Vec<InferType>)
A user struct or enum, applied to its type arguments (Box of Int is UserDefined(Box, [Int]); a type with no parameters has none). An EMPTY argument list also stands for a bare
reference to a generic type whose arguments were not written, and unifies with any
application of it.
Var(TyVar)
Function(Vec<InferType>, Box<InferType>)
Unknown
Implementations§
Source§impl InferType
impl InferType
Sourcepub fn from_type_expr(ty: &TypeExpr<'_>, interner: &Interner) -> InferType
pub fn from_type_expr(ty: &TypeExpr<'_>, interner: &Interner) -> InferType
Convert a TypeExpr AST node to InferType.
Unlike LogosType::from_type_expr, this correctly handles
TypeExpr::Function { inputs, output } by producing
InferType::Function(...) instead of Unknown.
Sourcepub fn from_type_expr_with_params(
ty: &TypeExpr<'_>,
interner: &Interner,
type_params: &HashMap<Symbol, TyVar>,
) -> InferType
pub fn from_type_expr_with_params( ty: &TypeExpr<'_>, interner: &Interner, type_params: &HashMap<Symbol, TyVar>, ) -> InferType
Convert a TypeExpr to InferType, substituting generic type parameters.
When type_params maps a name like T to a TyVar, any TypeExpr::Primitive(T)
or TypeExpr::Named(T) in the expression produces InferType::Var(tv) instead
of Unknown. This is used for generic function signatures where T is a type
parameter, not a concrete type name.
Sourcepub fn from_type_expr_in(ty: &TypeExpr<'_>, scope: &TypeScope<'_>) -> InferType
pub fn from_type_expr_in(ty: &TypeExpr<'_>, scope: &TypeScope<'_>) -> InferType
Convert a TypeExpr to InferType inside scope: a type parameter becomes the type it
stands for, and a user struct or enum becomes UserDefined applied to its arguments.
Sourcepub fn from_field_type(
ty: &FieldType,
interner: &Interner,
type_params: &HashMap<Symbol, TyVar>,
) -> InferType
pub fn from_field_type( ty: &FieldType, interner: &Interner, type_params: &HashMap<Symbol, TyVar>, ) -> InferType
Convert a registry FieldType to InferType.
type_params maps generic type parameter names (e.g., T, U) to
type variable indices allocated by UnificationTable::fresh.
Sourcepub fn from_field_type_in(ty: &FieldType, scope: &TypeScope<'_>) -> InferType
pub fn from_field_type_in(ty: &FieldType, scope: &TypeScope<'_>) -> InferType
Convert a registry FieldType to InferType inside scope — how a generic record’s field
is read at one application of the record (value: T of a Box of Int is Int).
Sourcepub fn from_literal(lit: &Literal) -> InferType
pub fn from_literal(lit: &Literal) -> InferType
Infer InferType from a literal value.
Sourcepub fn from_type_name(name: &str) -> InferType
pub fn from_type_name(name: &str) -> InferType
Parse a LOGOS type name into InferType.
Sourcepub fn describe(&self, interner: &Interner) -> String
pub fn describe(&self, interner: &Interner) -> String
Human-readable type name in Logos terms, for error messages: a user type by its own name
and arguments (Outcome, Box of Int).
Sourcepub fn to_logos_name(&self) -> String
pub fn to_logos_name(&self) -> String
describe where no interner is at hand: a user type reads as “a
user-defined type”.
Sourcepub fn primitive_name(&self) -> Option<&'static str>
pub fn primitive_name(&self) -> Option<&'static str>
The name a program writes for this type when it is one of the language’s own scalars
(Int, Real, Text, …); None for a collection, a user type, a function or a variable.
Sourcepub fn to_logos_type_ground(&self) -> LogosType
pub fn to_logos_type_ground(&self) -> LogosType
Convert a known-ground InferType to LogosType.
§Panics
Panics if called on a Var. Callers must zonk first.
Trait Implementations§
impl StructuralPartialEq for InferType
Auto Trait Implementations§
impl Freeze for InferType
impl RefUnwindSafe for InferType
impl Send for InferType
impl Sync for InferType
impl Unpin for InferType
impl UnsafeUnpin for InferType
impl UnwindSafe for InferType
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.