Enum erg_common::ty::Type
source · [−]pub enum Type {
Show 62 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,
RangeCommon,
FuncCommon,
ProcCommon,
FuncMethodCommon,
ProcMethodCommon,
CallableCommon,
ArrayCommon,
DictCommon,
NotImplemented,
Ellipsis,
Never,
Mono(Str),
Range(Box<Type>),
Iter(Box<Type>),
Ref(Box<Type>),
RefMut(Box<Type>),
Option(Box<Type>),
OptionMut(Box<Type>),
Subr(SubrType),
Callable {
param_ts: Vec<Type>,
return_t: Box<Type>,
},
Array {
t: Box<Type>,
len: TyParam,
},
Dict {
k: Box<Type>,
v: Box<Type>,
},
Tuple(Vec<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,
}
Expand description
NOTE: 連携型変数があるので、比較にはref_eq
を使うこと
Commonが付く型は多相だが中の型をなんでも受け入れるバージョン
TODO: MonoArray Int, 3 == PolyArray Int, Int, Int
Mut型を作ろうとすると、name() -> &strがうまくいかないので
組み込みMut型は全て書き下す
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
RangeCommon
FuncCommon
ProcCommon
FuncMethodCommon
ProcMethodCommon
CallableCommon
ArrayCommon
DictCommon
NotImplemented
Ellipsis
Never
Mono(Str)
Range(Box<Type>)
Iter(Box<Type>)
Ref(Box<Type>)
RefMut(Box<Type>)
Option(Box<Type>)
OptionMut(Box<Type>)
Subr(SubrType)
Callable
Array
Dict
Tuple(Vec<Type>)
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
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 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 refer(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 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 typaram_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>
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