Enum erg_common::ty::Type
source · [−]pub enum Type {
Show 48 variants
Obj,
ObjMut,
Int,
IntMut,
Nat,
NatMut,
Ratio,
RatioMut,
Float,
FloatMut,
Bool,
BoolMut,
Str,
StrMut,
NoneType,
Code,
Module,
Frame,
Error,
Inf,
NegInf,
Type,
Class,
Trait,
Patch,
NotImplemented,
Ellipsis,
Never,
Mono(Str),
Ref(Box<Type>),
RefMut(Box<Type>),
Subr(SubrType),
Callable {
param_ts: Vec<Type>,
return_t: Box<Type>,
},
Record(Dict<Str, Type>),
Refinement(RefinementType),
Quantified(QuantifiedType),
And(Vec<Type>),
Not(Vec<Type>),
Or(Vec<Type>),
VarArgs(Box<Type>),
Poly {
name: Str,
params: Vec<TyParam>,
},
MonoQVar(Str),
PolyQVar {
name: Str,
params: Vec<TyParam>,
},
FreeVar(FreeTyVar),
MonoProj {
lhs: Box<Type>,
rhs: Str,
},
ASTOmitted,
Failure,
Uninited,
}
Expand description
NOTE: 連携型変数があるので、比較にはref_eq
を使うこと
Variants
Obj
ObjMut
Int
IntMut
Nat
NatMut
Ratio
RatioMut
Float
FloatMut
Bool
BoolMut
Str
StrMut
NoneType
Code
Module
Frame
Error
Inf
NegInf
Type
Class
Trait
Patch
NotImplemented
Ellipsis
Never
Mono(Str)
Ref(Box<Type>)
RefMut(Box<Type>)
Subr(SubrType)
Callable
Record(Dict<Str, Type>)
Refinement(RefinementType)
Quantified(QuantifiedType)
And(Vec<Type>)
Not(Vec<Type>)
Or(Vec<Type>)
VarArgs(Box<Type>)
Poly
MonoQVar(Str)
PolyQVar
FreeVar(FreeTyVar)
MonoProj
ASTOmitted
Failure
Uninited
used to represent TyParam
is not initialized (see erg_compiler::context::instantiate_tp
)
Implementations
sourceimpl Type
impl Type
pub const OBJ: &'static Self = _
pub const NONE: &'static Self = _
pub const NOT_IMPLEMENTED: &'static Self = _
pub const ELLIPSIS: &'static Self = _
pub const INF: &'static Self = _
pub const NEG_INF: &'static Self = _
pub const NEVER: &'static Self = _
pub const FAILURE: &'static Self = _
pub fn free_var(level: usize, constraint: Constraint) -> Self
pub fn named_free_var(name: Str, level: usize, constraint: Constraint) -> Self
pub fn array(elem_t: Type, len: TyParam) -> Self
pub fn dict(k_t: Type, v_t: Type) -> Self
pub fn tuple(args: Vec<Type>) -> Self
pub fn var_args(elem_t: Type) -> Self
pub fn range(t: Type) -> Self
pub fn enum_t(s: Set<ValueObj>) -> Self
pub fn int_interval<P: Into<TyParam>, Q: Into<TyParam>>(
op: IntervalOp,
l: P,
r: Q
) -> Self
pub fn iter(t: Type) -> Self
pub fn ref_(t: Type) -> Self
pub fn ref_mut(t: Type) -> Self
pub fn option(t: Type) -> Self
pub fn option_mut(t: Type) -> Self
pub fn subr(
kind: SubrKind,
non_default_params: Vec<ParamTy>,
default_params: Vec<ParamTy>,
return_t: Type
) -> Self
pub fn func(
non_default_params: Vec<ParamTy>,
default_params: Vec<ParamTy>,
return_t: Type
) -> Self
pub fn func1(param_t: Type, return_t: Type) -> Self
pub fn kind1(param: Type) -> Self
pub fn func2(l: Type, r: Type, return_t: Type) -> Self
pub fn anon_param_func(
non_default_params: Vec<Type>,
default_params: Vec<Type>,
return_t: Type
) -> Self
pub fn proc(
non_default_params: Vec<ParamTy>,
default_params: Vec<ParamTy>,
return_t: Type
) -> Self
pub fn proc1(param_t: Type, return_t: Type) -> Self
pub fn proc2(l: Type, r: Type, return_t: Type) -> Self
pub fn anon_param_proc(
non_default_params: Vec<Type>,
default_params: Vec<Type>,
return_t: Type
) -> Self
pub fn fn_met(
self_t: Type,
non_default_params: Vec<ParamTy>,
default_params: Vec<ParamTy>,
return_t: Type
) -> Self
pub fn fn0_met(self_t: Type, return_t: Type) -> Self
pub fn fn1_met(self_t: Type, input_t: Type, return_t: Type) -> Self
pub fn anon_param_fn_met(
self_t: Type,
non_default_params: Vec<Type>,
default_params: Vec<Type>,
return_t: Type
) -> Self
pub fn pr_met(
self_before: Type,
self_after: Option<Type>,
non_default_params: Vec<ParamTy>,
default_params: Vec<ParamTy>,
return_t: Type
) -> Self
pub fn pr0_met(
self_before: Type,
self_after: Option<Type>,
return_t: Type
) -> Self
pub fn pr1_met(
self_before: Type,
self_after: Option<Type>,
input_t: Type,
return_t: Type
) -> Self
pub fn anon_param_pr_met(
self_before: Type,
self_after: Option<Type>,
non_default_params: Vec<Type>,
default_params: Vec<Type>,
return_t: Type
) -> Self
sourcepub fn nd_func(params: Vec<ParamTy>, ret: Type) -> Type
pub fn nd_func(params: Vec<ParamTy>, ret: Type) -> Type
function type with non-default parameters
pub fn nd_proc(params: Vec<ParamTy>, ret: Type) -> Type
pub fn callable(param_ts: Vec<Type>, return_t: Type) -> Self
pub fn mono<S: Into<Str>>(name: S) -> Self
pub fn mono_q<S: Into<Str>>(name: S) -> Self
pub fn poly<S: Into<Str>>(name: S, params: Vec<TyParam>) -> Self
pub fn poly_q<S: Into<Str>>(name: S, params: Vec<TyParam>) -> Self
pub fn mono_proj<S: Into<Str>>(lhs: Type, rhs: S) -> Self
sourcepub fn refinement(var: Str, t: Type, preds: Set<Predicate>) -> Self
pub fn refinement(var: Str, t: Type, preds: Set<Predicate>) -> Self
{I: Int | I >= 0}
=> Refinement{
layout: TyParam::MonoQ "I",
bounds: [TyBound::Instance("I", "Int")],
preds: [Predicate::GreaterEqual("I", 0)]
}
sourcepub fn quantified(unbound_t: Type, bounds: Set<TyBound>) -> Self
pub fn quantified(unbound_t: Type, bounds: Set<TyBound>) -> Self
quantified((T -> T), T: Type) => |T: Type| T -> T
pub fn is_mono_q(&self) -> bool
pub fn mutate(self) -> Self
pub fn is_mut(&self) -> bool
pub fn is_nonelike(&self) -> bool
pub fn args_ownership(&self) -> ArgsOwnership
pub fn ownership(&self) -> Ownership
pub fn rec_eq(&self, other: &Self) -> bool
sourcepub fn intersection(lhs: &Self, rhs: &Self) -> Self
pub fn intersection(lhs: &Self, rhs: &Self) -> Self
共通部分(A and B)を返す 型同士の包含関係はここでは検査しない(TypeCheckerでする)
pub fn name(&self) -> &str
pub const fn is_free_var(&self) -> bool
pub const fn is_varargs(&self) -> bool
pub fn is_monomorphic(&self) -> bool
pub const fn is_callable(&self) -> bool
pub fn has_unbound_var(&self) -> bool
pub fn has_no_unbound_var(&self) -> bool
pub fn typarams_len(&self) -> usize
pub fn typarams(&self) -> Vec<TyParam>
pub const fn self_t(&self) -> Option<&Type>
pub const fn non_default_params(&self) -> Option<&Vec<ParamTy>>
pub const fn default_params(&self) -> Option<&Vec<ParamTy>>
pub const fn return_t(&self) -> Option<&Type>
pub fn mut_return_t(&mut self) -> Option<&mut Type>
pub fn update_constraint(&self, new_constraint: Constraint)
Trait Implementations
sourceimpl From<RangeInclusive<&TyParam>> for Type
impl From<RangeInclusive<&TyParam>> for Type
sourcefn from(r: RangeInclusive<&TyParam>) -> Self
fn from(r: RangeInclusive<&TyParam>) -> Self
Converts to this type from the input type.
sourceimpl From<RangeInclusive<TyParam>> for Type
impl From<RangeInclusive<TyParam>> for Type
sourcefn from(r: RangeInclusive<TyParam>) -> Self
fn from(r: RangeInclusive<TyParam>) -> Self
Converts to this type from the input type.
impl Eq for Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations
impl !RefUnwindSafe for Type
impl !Send for Type
impl !Sync for Type
impl Unpin for Type
impl !UnwindSafe for Type
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more