Struct TypeChecker

Source
pub struct TypeChecker<S: Sort> { /* private fields */ }

Implementations§

Source§

impl<S: Sort> TypeChecker<S>

Source

pub fn new() -> TypeChecker<S>

Source

pub fn new_type_variable(&mut self, span: Span) -> TypeRef<S>

Source

pub fn new_attached_type_variable( &mut self, span: Span, pointer: *mut Option<GroundSort<S>>, ) -> TypeRef<S>

Source

pub fn assert_equal<A: Into<TypeRef<S>>, B: Into<TypeRef<S>>>( &mut self, expected: A, given: B, )

Add a new constraint to the type checker.

Even of the system is not satisfiable, this function never fail. Type errors are detected with the TypeChecker::resolve method.

Source

pub fn var(&self, index: usize) -> &TypeRef<S>

Source

pub fn push<T: Into<TypeRef<S>>>(&mut self, ty: T)

Source

pub fn pop(&mut self, len: usize)

Source

pub fn enter(&mut self, span: Span)

Source

pub fn leave(&mut self)

Source

pub fn location(&self) -> Span

Source

pub fn representant(&self, id: usize) -> (usize, TypeRef<S>)

Source

pub fn redirected(&self, ty: &TypeRef<S>) -> TypeRef<S>

Source

pub fn unify( &self, expected: TypeRef<S>, given: TypeRef<S>, root: bool, span: Span, ) -> Result<(TypeRef<S>, Vec<Constraint<S>>), SortMissmatch<S>>

Source

pub fn resolve(&mut self) -> Result<(), S>

Resolve all the constraints.

Source

pub unsafe fn apply(&self) -> Result<(), S>

Apply the resolved types.

Auto Trait Implementations§

§

impl<S> Freeze for TypeChecker<S>

§

impl<S> RefUnwindSafe for TypeChecker<S>
where S: RefUnwindSafe,

§

impl<S> !Send for TypeChecker<S>

§

impl<S> !Sync for TypeChecker<S>

§

impl<S> Unpin for TypeChecker<S>
where S: Unpin,

§

impl<S> UnwindSafe for TypeChecker<S>

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.