Struct kailua_types::ty::Ty
[−]
[src]
pub struct Ty { /* fields omitted */ }
A value type, which is also a sort of pointer (to handle recursively defined T
).
The full value type consists of a non-nilable portion (T
), the nil
(Nil
),
an optional type tag (Tag
) and an optional display name (DisplayName
).
Methods
impl Ty
[src]
fn dummy() -> Ty
fn silent_nil() -> Ty
fn noisy_nil() -> Ty
fn new(ty: T<'static>) -> Ty
fn from_kind(kind: &Spanned<Kind>, resolv: &mut TypeResolver) -> Result<Ty>
fn nil(&self) -> Nil
fn or_nil(self, nil: Nil) -> Ty
fn with_nil(self) -> Ty
fn without_nil(self) -> Ty
fn union_nil(self, nil: Nil) -> Ty
fn can_omit(&self) -> bool
fn tag(&self) -> Option<Tag>
fn with_tag<T: Into<Option<Tag>>>(self, tag: T) -> Ty
fn and_display(self, disp: DisplayName) -> Ty
fn truthy(self) -> Ty
fn falsy(self) -> Ty
fn is_dynamic(&self) -> bool
fn is_integral(&self) -> bool
fn is_numeric(&self) -> bool
fn is_stringy(&self) -> bool
fn is_tabular(&self) -> bool
fn is_callable(&self) -> bool
fn is_truthy(&self) -> bool
fn is_falsy(&self) -> bool
fn as_string(&self) -> Option<&Str>
fn as_integer(&self) -> Option<i32>
fn coerce(self) -> Ty
fn generalize(self, ctx: &mut TypeContext) -> Ty
fn flags(&self) -> Flags
fn filter_by_flags(self, flags: Flags, ctx: &mut TypeContext) -> TypeResult<Ty>
fn unwrap(self) -> T<'static>
Methods from Deref<Target = T<'static>>
fn flags(&self) -> Flags
fn to_ref<'b: 'a>(&'b self) -> T<'b>
fn truthy<'b>(&'b self) -> Cow<'b, T<'a>>
fn falsy<'b>(&'b self) -> Cow<'b, T<'a>>
fn is_dynamic(&self) -> bool
fn is_integral(&self) -> bool
fn is_numeric(&self) -> bool
fn is_stringy(&self) -> bool
fn is_tabular(&self) -> bool
fn is_callable(&self) -> bool
fn is_truthy(&self) -> bool
fn is_falsy(&self) -> bool
fn get_dynamic(&self) -> Option<Dyn>
fn get_tables(&self) -> Option<&Tables>
fn get_functions(&self) -> Option<&Functions>
fn get_tvar(&self) -> Option<TVar>
fn as_string(&self) -> Option<&Str>
fn as_integer(&self) -> Option<i32>
fn coerce<'b>(&'b self) -> Cow<'b, T<'a>>
Coerces "implicit" types into "explicit" types.
This is the only possible way in Kailua for implicit coercions to happen, and does the following:
- Removes implicit literal types from
self
, by replacing them withboolean
,integer
orstring
. This does not affect explicit literal types fromTy::from_kind
. (This happens in the shallow way, as implicit types are incrementally constructed.)
This is used when new variable or field has been added without explicit types, or upper & exact bounds for type variables get updated (lower bounds do not).
fn generalize(self, ctx: &mut TypeContext) -> T<'static>
Replaces type and row variables present in given type to their fresh copies.
Primarily used for function calls where all type variable and row variables are made fresh per each call, so that prior calls cannot affect constraints to later calls.
fn into_send(self) -> T<'static>
fn filter_by_flags<'b>(
&'b self,
flags: Flags,
ctx: &mut TypeContext
) -> TypeResult<Cow<'b, T<'a>>>
&'b self,
flags: Flags,
ctx: &mut TypeContext
) -> TypeResult<Cow<'b, T<'a>>>
Trait Implementations
impl Clone for Ty
[src]
fn clone(&self) -> Ty
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Ty
[src]
fn eq(&self, __arg_0: &Ty) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Ty) -> bool
This method tests for !=
.
impl Dummy for Ty
[src]
impl<'a> From<T<'a>> for Ty
[src]
impl Deref for Ty
[src]
type Target = T<'static>
The resulting type after dereferencing
fn deref(&self) -> &T<'static>
The method called to dereference a value
impl DerefMut for Ty
[src]
impl<'a> Union<T<'a>> for Ty
[src]
type Output = Ty
A type of the resulting type.
fn union(
&self,
other: &T<'a>,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
&self,
other: &T<'a>,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
Calculates a union type of self
and other
, explicitly or implicitly. Read more
impl<'a> Lattice<T<'a>> for Ty
[src]
fn assert_sub(&self, other: &T<'a>, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent subtype of other
under the type context.
fn assert_eq(&self, other: &T<'a>, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent type equal to other
under the type context.
impl Union<Ty> for Ty
[src]
type Output = Ty
A type of the resulting type.
fn union(
&self,
other: &Ty,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
&self,
other: &Ty,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
Calculates a union type of self
and other
, explicitly or implicitly. Read more
impl Lattice<Ty> for Ty
[src]
fn assert_sub(&self, other: &Ty, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent subtype of other
under the type context.
fn assert_eq(&self, other: &Ty, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent type equal to other
under the type context.