pub struct TypeSystem {
pub env: TypeEnv,
pub classes: ClassEnv,
pub adts: HashMap<Symbol, AdtDecl>,
pub class_info: HashMap<Symbol, ClassInfo>,
pub class_methods: HashMap<Symbol, ClassMethodInfo>,
pub declared_values: HashSet<Symbol>,
pub supply: TypeVarSupply,
/* private fields */
}Fields§
§env: TypeEnv§classes: ClassEnv§adts: HashMap<Symbol, AdtDecl>§class_info: HashMap<Symbol, ClassInfo>§class_methods: HashMap<Symbol, ClassMethodInfo>§declared_values: HashSet<Symbol>Names introduced by declare fn (forward declarations).
These are placeholders in the type environment and must not block a later
real definition (e.g. fn foo = ... or host/CLI injection).
supply: TypeVarSupplyImplementations§
Source§impl TypeSystem
impl TypeSystem
pub fn new() -> Self
pub fn fresh_type_var(&mut self, name: Option<Symbol>) -> TypeVar
pub fn set_limits(&mut self, limits: TypeSystemLimits)
pub fn with_prelude() -> Result<Self, TypeError>
pub fn inject_decl(&mut self, decl: &Decl) -> Result<(), TypeError>
pub fn inject_decls(&mut self, decls: &[Decl]) -> Result<(), TypeError>
pub fn add_value(&mut self, name: impl AsRef<str>, scheme: Scheme)
pub fn add_overload(&mut self, name: impl AsRef<str>, scheme: Scheme)
pub fn inject_class(&mut self, name: impl AsRef<str>, supers: Vec<Symbol>)
pub fn inject_instance(&mut self, class: impl AsRef<str>, inst: Instance)
pub fn inject_class_decl(&mut self, decl: &ClassDecl) -> Result<(), TypeError>
pub fn inject_instance_decl( &mut self, decl: &InstanceDecl, ) -> Result<PreparedInstanceDecl, TypeError>
pub fn prepare_instance_decl( &mut self, decl: &InstanceDecl, ) -> Result<PreparedInstanceDecl, TypeError>
pub fn inject_fn_decl(&mut self, decl: &FnDecl) -> Result<(), TypeError>
pub fn inject_fn_decls(&mut self, decls: &[FnDecl]) -> Result<(), TypeError>
pub fn inject_declare_fn_decl( &mut self, decl: &DeclareFnDecl, ) -> Result<(), TypeError>
pub fn instantiate_class_method_for_head( &mut self, class: &Symbol, method: &Symbol, head: &Type, ) -> Result<Type, TypeError>
pub fn typecheck_instance_method( &mut self, prepared: &PreparedInstanceDecl, method: &InstanceMethodImpl, ) -> Result<TypedExpr, TypeError>
Sourcepub fn inject_adt(&mut self, adt: &AdtDecl)
pub fn inject_adt(&mut self, adt: &AdtDecl)
Register constructor schemes for an ADT in the type environment.
This makes constructors (e.g. Some, None, Ok, Err) available
to the type checker as normal values.
pub fn adt_from_decl(&mut self, decl: &TypeDecl) -> Result<AdtDecl, TypeError>
pub fn inject_type_decl(&mut self, decl: &TypeDecl) -> Result<(), TypeError>
pub fn infer_typed( &mut self, expr: &Expr, ) -> Result<(TypedExpr, Vec<Predicate>, Type), TypeError>
pub fn infer_typed_with_gas( &mut self, expr: &Expr, gas: &mut GasMeter, ) -> Result<(TypedExpr, Vec<Predicate>, Type), TypeError>
pub fn infer( &mut self, expr: &Expr, ) -> Result<(Vec<Predicate>, Type), TypeError>
pub fn infer_with_gas( &mut self, expr: &Expr, gas: &mut GasMeter, ) -> Result<(Vec<Predicate>, Type), TypeError>
Trait Implementations§
Source§impl Clone for TypeSystem
impl Clone for TypeSystem
Source§fn clone(&self) -> TypeSystem
fn clone(&self) -> TypeSystem
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TypeSystem
impl Debug for TypeSystem
Source§impl Default for TypeSystem
impl Default for TypeSystem
Source§fn default() -> TypeSystem
fn default() -> TypeSystem
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TypeSystem
impl RefUnwindSafe for TypeSystem
impl Send for TypeSystem
impl Sync for TypeSystem
impl Unpin for TypeSystem
impl UnsafeUnpin for TypeSystem
impl UnwindSafe for TypeSystem
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
Mutably borrows from an owned value. Read more