pub struct Substitution<T>
where T: Substitutable,
{ /* private fields */ }

Implementations§

source§

impl<T> Substitution<T>
where T: Substitutable,

source

pub fn new(factory: T::Factory, interner: T::Interner) -> Substitution<T>

source

pub fn var_id(&self) -> u32

source

pub fn insert(&self, var: u32, t: T)

source

pub fn replace(&mut self, var: u32, t: T)

source

pub fn reset(&mut self, var: u32)

source

pub fn snapshot(&mut self) -> Snapshot

source

pub fn commit(&mut self, snapshot: Snapshot)

source

pub fn rollback_to(&mut self, snapshot: Snapshot)

source

pub fn clear_from(&mut self, level: u32)

Assumes that no variables unified with anything (but variables < level may exist)

source

pub fn new_var(&self) -> T
where T: Clone + Display,

Creates a new variable

source

pub fn new_var_fn<F>(&self, f: F) -> T
where T: Clone, F: FnOnce(u32) -> T,

source

pub fn real<'r>(&'r self, typ: &'r T) -> &'r T

If typ is a variable this returns the real unified value of that variable. Otherwise it just returns the type itself. Note that the returned type may contain terms which also need to have real called on them.

source

pub fn get_var(&self, var: u32) -> Option<&T>

source

pub fn find_type_for_var(&self, var: u32) -> Option<&T>

source

pub fn get_level(&self, var: u32) -> u32

source

pub fn replace_variable(&self, typ: &T) -> Option<T>
where T: Clone,

source§

impl<T: Substitutable + Clone> Substitution<T>

source

pub fn make_real(&self, typ: &mut T)

source§

impl<T: Substitutable + PartialEq + Clone> Substitution<T>

source

pub fn union(&self, variable: &T, typ: &T) -> Result<(), Error<T>>
where T::Variable: Clone, T: Display,

Takes id and updates the substitution to say that it should have the same type as typ

source§

impl Substitution<RcType>

source

pub fn new_skolem(&self, name: Symbol, kind: ArcKind) -> RcType

source

pub fn zonk(&self, typ: &RcType) -> RcType

source

pub fn bind_arc(&self, typ: &RcType) -> ArcType

Trait Implementations§

source§

impl<T> Debug for Substitution<T>
where T: Debug + Substitutable,

source§

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

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

impl<T> Default for Substitution<T>

source§

fn default() -> Substitution<T>

Returns the “default value” for a type. Read more
source§

impl<'a> Substitution<Symbol, ArcType> for &'a Substitution<RcType>

source§

fn new_var(&mut self) -> RcType

source§

fn new_skolem(&mut self, name: Symbol, kind: ArcKind) -> RcType

source§

impl<'a, T> TypeContext<Symbol, T> for &'a Substitution<T>
where T: Substitutable + TypePtr<Id = Symbol> + From<Type<Symbol, T>>, &'a T::Interner: TypeContext<Symbol, T>,

source§

fn intern(&mut self, typ: Type<Symbol, T>) -> T

source§

fn intern_types( &mut self, types: impl IntoIterator<Item = T> ) -> <T as TypePtr>::Types

source§

fn intern_generics( &mut self, types: impl IntoIterator<Item = Generic<Symbol>> ) -> <T as TypePtr>::Generics

source§

fn intern_fields( &mut self, types: impl IntoIterator<Item = Field<<T as TypePtr>::SpannedId, T>> ) -> <T as TypePtr>::Fields

source§

fn intern_type_fields( &mut self, types: impl IntoIterator<Item = Field<<T as TypePtr>::SpannedId, Alias<Symbol, T>>> ) -> <T as TypePtr>::TypeFields

source§

fn intern_flags(&mut self, typ: Type<Symbol, T>, flags: Flags) -> T

source§

fn builtin(&mut self, typ: BuiltinType) -> T

source§

fn forall(&mut self, params: <T as TypePtr>::Generics, typ: T) -> T

source§

fn with_forall(&mut self, typ: T, from: &T) -> T

source§

fn array(&mut self, typ: T) -> T

source§

fn app(&mut self, id: T, args: <T as TypePtr>::Types) -> T

source§

fn variant(&mut self, fields: <T as TypePtr>::Fields) -> T

source§

fn poly_variant(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn effect(&mut self, fields: <T as TypePtr>::Fields) -> T

source§

fn poly_effect(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn record( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields ) -> T

source§

fn poly_record( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields, rest: T ) -> T

source§

fn extend_full_row( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields, rest: T ) -> T

source§

fn extend_row(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn extend_type_row(&mut self, types: <T as TypePtr>::TypeFields, rest: T) -> T

source§

fn generic(&mut self, typ: Generic<Symbol>) -> T

source§

fn skolem(&mut self, typ: Skolem<Symbol>) -> T

source§

fn variable(&mut self, typ: TypeVariable) -> T

source§

fn alias(&mut self, name: Symbol, args: <T as TypePtr>::Generics, typ: T) -> T

source§

fn ident(&mut self, id: KindedIdent<Symbol>) -> T

source§

fn projection(&mut self, id: AppVec<Symbol>) -> T

source§

fn builtin_type(&mut self, typ: BuiltinType) -> T

source§

fn new_alias( &mut self, name: Symbol, args: <T as TypePtr>::Generics, typ: T ) -> Alias<Symbol, T>

source§

fn new_data_alias(&mut self, data: AliasData<Symbol, T>) -> Alias<Symbol, T>

source§

fn alias_group( &mut self, group: Vec<AliasData<Symbol, T>> ) -> Vec<Alias<Symbol, T>>
where T: TypeExt<Id = Symbol>, Symbol: PartialEq,

source§

fn hole(&mut self) -> T

source§

fn opaque(&mut self) -> T

source§

fn error(&mut self) -> T

source§

fn array_builtin(&mut self) -> T

source§

fn empty_row(&mut self) -> T

source§

fn function_builtin(&mut self) -> T

source§

fn string(&mut self) -> T

source§

fn char(&mut self) -> T

source§

fn byte(&mut self) -> T

source§

fn int(&mut self) -> T

source§

fn float(&mut self) -> T

source§

fn unit(&mut self) -> T

source§

fn function<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_implicit<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_type<I>(&mut self, arg_type: ArgType, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

impl<T> TypeContext<Symbol, T> for Substitution<T>
where T: Substitutable + TypePtr<Id = Symbol> + From<Type<Symbol, T>>, for<'a> &'a T::Interner: TypeContext<Symbol, T>,

source§

fn intern(&mut self, typ: Type<Symbol, T>) -> T

source§

fn intern_types( &mut self, types: impl IntoIterator<Item = T> ) -> <T as TypePtr>::Types

source§

fn intern_generics( &mut self, types: impl IntoIterator<Item = Generic<Symbol>> ) -> <T as TypePtr>::Generics

source§

fn intern_fields( &mut self, types: impl IntoIterator<Item = Field<<T as TypePtr>::SpannedId, T>> ) -> <T as TypePtr>::Fields

source§

fn intern_type_fields( &mut self, types: impl IntoIterator<Item = Field<<T as TypePtr>::SpannedId, Alias<Symbol, T>>> ) -> <T as TypePtr>::TypeFields

source§

fn intern_flags(&mut self, typ: Type<Symbol, T>, flags: Flags) -> T

source§

fn builtin(&mut self, typ: BuiltinType) -> T

source§

fn forall(&mut self, params: <T as TypePtr>::Generics, typ: T) -> T

source§

fn with_forall(&mut self, typ: T, from: &T) -> T

source§

fn array(&mut self, typ: T) -> T

source§

fn app(&mut self, id: T, args: <T as TypePtr>::Types) -> T

source§

fn variant(&mut self, fields: <T as TypePtr>::Fields) -> T

source§

fn poly_variant(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn effect(&mut self, fields: <T as TypePtr>::Fields) -> T

source§

fn poly_effect(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn record( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields ) -> T

source§

fn poly_record( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields, rest: T ) -> T

source§

fn extend_full_row( &mut self, types: <T as TypePtr>::TypeFields, fields: <T as TypePtr>::Fields, rest: T ) -> T

source§

fn extend_row(&mut self, fields: <T as TypePtr>::Fields, rest: T) -> T

source§

fn extend_type_row(&mut self, types: <T as TypePtr>::TypeFields, rest: T) -> T

source§

fn generic(&mut self, typ: Generic<Symbol>) -> T

source§

fn skolem(&mut self, typ: Skolem<Symbol>) -> T

source§

fn variable(&mut self, typ: TypeVariable) -> T

source§

fn alias(&mut self, name: Symbol, args: <T as TypePtr>::Generics, typ: T) -> T

source§

fn ident(&mut self, id: KindedIdent<Symbol>) -> T

source§

fn projection(&mut self, id: AppVec<Symbol>) -> T

source§

fn builtin_type(&mut self, typ: BuiltinType) -> T

source§

fn new_alias( &mut self, name: Symbol, args: <T as TypePtr>::Generics, typ: T ) -> Alias<Symbol, T>

source§

fn new_data_alias(&mut self, data: AliasData<Symbol, T>) -> Alias<Symbol, T>

source§

fn alias_group( &mut self, group: Vec<AliasData<Symbol, T>> ) -> Vec<Alias<Symbol, T>>
where T: TypeExt<Id = Symbol>, Symbol: PartialEq,

source§

fn hole(&mut self) -> T

source§

fn opaque(&mut self) -> T

source§

fn error(&mut self) -> T

source§

fn array_builtin(&mut self) -> T

source§

fn empty_row(&mut self) -> T

source§

fn function_builtin(&mut self) -> T

source§

fn string(&mut self) -> T

source§

fn char(&mut self) -> T

source§

fn byte(&mut self) -> T

source§

fn int(&mut self) -> T

source§

fn float(&mut self) -> T

source§

fn unit(&mut self) -> T

source§

fn function<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_implicit<I>(&mut self, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

source§

fn function_type<I>(&mut self, arg_type: ArgType, args: I, ret: T) -> T
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: DoubleEndedIterator<Item = T>,

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<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

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>,

§

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>,

§

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.
§

impl<T> Any for T
where T: Any,