Enum erg_compiler::ty::typaram::TyParam

source ·
pub enum TyParam {
Show 19 variants Value(ValueObj), Type(Box<Type>), List(Vec<TyParam>), UnsizedList(Box<TyParam>), Tuple(Vec<TyParam>), Set(Set<TyParam>), Dict(Dict<TyParam, TyParam>), Record(Dict<Field, TyParam>), DataClass { name: Str, fields: Dict<Field, TyParam>, }, Lambda(TyParamLambda), Mono(Str), Proj { obj: Box<TyParam>, attr: Str, }, ProjCall { obj: Box<TyParam>, attr: Str, args: Vec<TyParam>, }, App { name: Str, args: Vec<TyParam>, }, UnaryOp { op: OpKind, val: Box<TyParam>, }, BinOp { op: OpKind, lhs: Box<TyParam>, rhs: Box<TyParam>, }, Erased(Box<Type>), FreeVar(FreeTyParam), Failure,
}
Expand description

§type parameter

Unevaluated expressions that types can have inside

The evaluated one becomes ValueObj.

  • Literal: 1, “aa”, True, None, … (don’t use container literals, they can only hold literals)
  • Type: Int, Add(?R, ?O), …
  • Mono: I, N, …
  • Attr: math.PI, …
  • List: [1, 2, N]
  • Tuple: (1, N, True)
  • App: List(Int), Fib(10), …
  • QuantVar: N: Nat, …
  • FreeVar: ?I: Int, …
  • UnaryOp: -N, ~B, …
  • BinOp: 1 + 1, N * 2, …
  • Erased: _: Type, _: Nat, …

Variants§

§

Value(ValueObj)

§

Type(Box<Type>)

§

List(Vec<TyParam>)

§

UnsizedList(Box<TyParam>)

§

Tuple(Vec<TyParam>)

§

Set(Set<TyParam>)

§

Dict(Dict<TyParam, TyParam>)

§

Record(Dict<Field, TyParam>)

§

DataClass

Fields

§name: Str
§fields: Dict<Field, TyParam>
§

Lambda(TyParamLambda)

§

Mono(Str)

§

Proj

Fields

§attr: Str
§

ProjCall

Fields

§attr: Str
§args: Vec<TyParam>
§

App

Fields

§name: Str
§args: Vec<TyParam>
§

UnaryOp

Fields

§

BinOp

Fields

§

Erased(Box<Type>)

§

FreeVar(FreeTyParam)

§

Failure

Implementations§

source§

impl TyParam

source

pub fn t(t: Type) -> Self

source

pub fn mono<S: Into<Str>>(name: S) -> Self

source

pub fn mono_q<S: Into<Str>>(name: S, constr: Constraint) -> Self

source

pub fn proj<S: Into<Str>>(self, attr: S) -> Self

source

pub fn proj_call(self, attr: Str, args: Vec<TyParam>) -> Self

source

pub fn range(start: Self, end: Self) -> Self

source

pub fn free_instance(level: usize, t: Type) -> Self

source

pub fn free_var(level: usize, constr: Constraint) -> Self

source

pub fn named_free_var(name: Str, level: usize, constr: Constraint) -> Self

source

pub fn value<V: Into<ValueObj>>(v: V) -> Self

NOTE: Always add postfix when entering numbers. For example, value(1) will be of type Int.

source

pub fn unary(op: OpKind, val: TyParam) -> Self

source

pub fn bin(op: OpKind, lhs: TyParam, rhs: TyParam) -> Self

source

pub fn app(name: Str, args: Vec<TyParam>) -> Self

source

pub fn erased(t: Type) -> Self

source

pub fn unsized_list(elem: TyParam) -> Self

source

pub fn succ(self) -> Self

source

pub fn pred(self) -> Self

source

pub fn qual_name(&self) -> Option<Str>

source

pub fn local_name(&self) -> Option<Str>

source

pub fn tvar_name(&self) -> Option<Str>

source

pub fn cheap_cmp(&self, r: &TyParam) -> Option<TyParamOrdering>

source

pub fn coerce(&self, list: Option<&UndoableLinkedList>)

source

pub fn undoable_coerce(&self, list: &UndoableLinkedList)

source

pub fn destructive_coerce(&self)

source

pub fn qvars(&self) -> Set<(Str, Constraint)>

source

pub fn has_qvar(&self) -> bool

source

pub fn contains_tvar(&self, target: &FreeTyVar) -> bool

source

pub fn contains_type(&self, target: &Type) -> bool

source

pub fn contains_tp(&self, target: &TyParam) -> bool

source

pub fn is_recursive(&self) -> bool

source

pub fn is_unbound_var(&self) -> bool

source

pub fn has_unbound_var(&self) -> bool

source

pub fn has_no_unbound_var(&self) -> bool

source

pub fn has_undoable_linked_var(&self) -> bool

source

pub fn union_size(&self) -> usize

source

pub fn has_upper_bound(&self) -> bool

source

pub fn has_lower_bound(&self) -> bool

source

pub fn is_erased(&self) -> bool

source

pub fn is_type(&self) -> bool

source

pub fn substitute(self, var: &str, to: &TyParam) -> TyParam

source

pub fn replace(self, target: &TyParam, to: &TyParam) -> TyParam

source

pub fn replace_t(self, target: &Type, to: &Type) -> TyParam

source

pub fn normalize(self) -> TyParam

TyParam::Value(ValueObj::Type(_)) => TyParam::Type

source

pub fn typarams(&self) -> Vec<TyParam>

source

pub fn contained_ts(&self) -> Set<Type>

source

pub fn dereference(&mut self)

source

pub fn namespace(&self) -> Str

source

pub fn variables(&self) -> Set<Str>

Trait Implementations§

source§

impl Add for TyParam

§

type Output = TyParam

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl CanbeFree for TyParam

source§

fn unbound_name(&self) -> Option<Str>

source§

fn constraint(&self) -> Option<Constraint>

source§

fn destructive_update_constraint( &self, new_constraint: Constraint, in_instantiation: bool )

source§

impl Clone for TyParam

source§

fn clone(&self) -> TyParam

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TyParam

source§

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

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

impl Default for TyParam

source§

fn default() -> Self

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

impl Display for TyParam

source§

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

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

impl Div for TyParam

§

type Output = TyParam

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl From<Dict<Type, Type>> for TyParam

source§

fn from(v: Dict<Type, Type>) -> Self

Converts to this type from the input type.
source§

impl From<Range<&TyParam>> for TyParam

source§

fn from(r: Range<&TyParam>) -> Self

Converts to this type from the input type.
source§

impl From<Range<TyParam>> for TyParam

source§

fn from(r: Range<TyParam>) -> Self

Converts to this type from the input type.
source§

impl From<RangeInclusive<&TyParam>> for TyParam

source§

fn from(r: RangeInclusive<&TyParam>) -> Self

Converts to this type from the input type.
source§

impl From<RangeInclusive<TyParam>> for TyParam

source§

fn from(r: RangeInclusive<TyParam>) -> Self

Converts to this type from the input type.
source§

impl<V: Into<ValueObj>> From<V> for TyParam

source§

fn from(v: V) -> Self

Converts to this type from the input type.
source§

impl HasLevel for TyParam

source§

fn level(&self) -> Option<Level>

source§

fn set_level(&self, level: Level)

source§

fn set_lower(&self, level: Level)

source§

fn lift(&self)

source§

fn lower(&self)

source§

fn generalize(&self)

source§

fn is_generalized(&self) -> bool

source§

impl Hash for TyParam

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LimitedDisplay for TyParam

source§

fn limited_fmt<W: Write>(&self, f: &mut W, limit: isize) -> Result

If limit was set to a negative value, it will be displayed without abbreviation. FIXME:
source§

fn to_string_unabbreviated(&self) -> String

source§

impl Mul for TyParam

§

type Output = TyParam

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for TyParam

§

type Output = TyParam

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for TyParam

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralEq for TyParam

source§

fn structural_eq(&self, other: &Self) -> bool

source§

impl Sub for TyParam

§

type Output = TyParam

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<'t> TryFrom<&'t TyParam> for &'t FreeTyParam

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(t: &'t TyParam) -> Result<&'t FreeTyParam, ()>

Performs the conversion.
source§

impl<'t> TryFrom<&'t TyParam> for &'t FreeTyVar

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(t: &'t TyParam) -> Result<&'t FreeTyVar, ()>

Performs the conversion.
source§

impl<'a> TryFrom<&'a TyParam> for &'a Type

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(tp: &'a TyParam) -> Result<&'a Type, ()>

Performs the conversion.
source§

impl TryFrom<&TyParam> for usize

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(tp: &TyParam) -> Result<Self, ()>

Performs the conversion.
source§

impl TryFrom<TyParam> for Dict<TyParam, TyParam>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(tp: TyParam) -> Result<Self, ()>

Performs the conversion.
source§

impl TryFrom<TyParam> for ValueObj

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(tp: TyParam) -> Result<Self, ()>

Performs the conversion.
source§

impl TryFrom<TyParam> for Vec<TyParam>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(tp: TyParam) -> Result<Self, ()>

Performs the conversion.
source§

impl Eq for TyParam

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<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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.