[][src]Enum gluon_base::types::Type

pub enum Type<Id, T: TypePtr<Id = Id> = ArcType<Id>> {
    Hole,
    Opaque,
    Error,
    Builtin(BuiltinType),
    Forall(T::Generics, T),
    App(T, T::Types),
    Function(ArgType, T, T),
    Record(T),
    Variant(T),
    Effect(T),
    EmptyRow,
    ExtendRow {
        fields: T::Fields,
        rest: T,
    },
    ExtendTypeRow {
        types: T::TypeFields,
        rest: T,
    },
    Ident(KindedIdent<Id>),
    Projection(AppVec<Id>),
    Variable(TypeVariable),
    Generic(Generic<Id>),
    Alias(AliasRef<Id, T>),
    Skolem(Skolem<Id>),
}

The representation of gluon's types.

For efficiency this enum is not stored directly but instead a pointer wrapper which derefs to Type is used to enable types to be shared. It is recommended to use the static functions on Type such as Type::app and Type::record when constructing types as those will construct the pointer wrapper directly.

Variants

Hole

An unbound type _, awaiting ascription.

Opaque

An opaque type

Error

A type used to mark type errors

Builtin(BuiltinType)

A builtin type

Forall(T::Generics, T)

Universally quantified types

App(T, T::Types)

A type application with multiple arguments. For example, Map String Int would be represented as App(Map, [String, Int]).

Function(ArgType, T, T)

Function type which can have a explicit or implicit argument

Record(T)

Record constructor, of kind Row -> Type

Variant(T)

Variant constructor, of kind Row -> Type

Effect(T)

Effect constructor, of kind Row -> Type -> Type

EmptyRow

The empty row, of kind Row

ExtendRow

Row extension, of kind ... -> Row -> Row

Fields of ExtendRow

fields: T::Fields

The fields of this record type

rest: T

The rest of the row

ExtendTypeRow

Row extension, of kind ... -> Row -> Row

Fields of ExtendTypeRow

types: T::TypeFields

The associated types of this record type

rest: T

The rest of the row

Ident(KindedIdent<Id>)

An identifier type. These are created during parsing, but should all be resolved into Type::Aliases during type checking.

Identifiers are also sometimes used inside aliased types to avoid cycles in reference counted pointers. This is a bit of a wart at the moment and may cause spurious unification failures.

Projection(AppVec<Id>)
Variable(TypeVariable)

An unbound type variable that may be unified with other types. These will eventually be converted into Type::Generics during generalization.

Generic(Generic<Id>)

A variable that needs to be instantiated with a fresh type variable when the binding is referred to.

Alias(AliasRef<Id, T>)
Skolem(Skolem<Id>)

Implementations

impl<Id, T> Type<Id, T> where
    T: TypePtr<Id = Id>, 
[src]

impl<Id, T> Type<Id, T> where
    T: From<Type<Id, T>> + TypeExt<Id = Id>,
    T::Types: Default + Extend<T>, 
[src]

pub fn hole() -> T[src]

pub fn opaque() -> T[src]

pub fn error() -> T[src]

pub fn builtin(typ: BuiltinType) -> T[src]

pub fn forall(params: Vec<Generic<Id>>, typ: T) -> T[src]

pub fn array(typ: T) -> T[src]

pub fn array_builtin() -> T[src]

pub fn app(id: T, args: T::Types) -> T[src]

pub fn variant(fields: Vec<Field<T::SpannedId, T>>) -> T[src]

pub fn poly_variant(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T[src]

pub fn effect(fields: Vec<Field<T::SpannedId, T>>) -> T[src]

pub fn poly_effect(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T[src]

pub fn tuple<S: ?Sized, I>(symbols: &mut S, elems: I) -> T where
    S: IdentEnv<Ident = Id>,
    T::SpannedId: From<Id>,
    I: IntoIterator<Item = T>,
    T: From<(Type<Id, T>, Flags)>, 
[src]

pub fn tuple_<S: ?Sized, I>(symbols: &mut S, elems: I) -> Type<Id, T> where
    S: IdentEnv<Ident = Id>,
    T::SpannedId: From<Id>,
    I: IntoIterator<Item = T>,
    T: From<(Type<Id, T>, Flags)>, 
[src]

pub fn record(
    types: Vec<Field<T::SpannedId, Alias<Id, T>>>,
    fields: Vec<Field<T::SpannedId, T>>
) -> T
[src]

pub fn poly_record(
    types: Vec<Field<T::SpannedId, Alias<Id, T>>>,
    fields: Vec<Field<T::SpannedId, T>>,
    rest: T
) -> T
[src]

pub fn extend_full_row(
    types: Vec<Field<T::SpannedId, Alias<Id, T>>>,
    fields: Vec<Field<T::SpannedId, T>>,
    rest: T
) -> T
[src]

pub fn extend_row(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T[src]

pub fn extend_type_row(
    types: Vec<Field<T::SpannedId, Alias<Id, T>>>,
    rest: T
) -> T
[src]

pub fn empty_row() -> T[src]

pub fn function<I>(args: I, ret: T) -> T where
    I: IntoIterator<Item = T>,
    I::IntoIter: DoubleEndedIterator<Item = T>, 
[src]

pub fn function_implicit<I>(args: I, ret: T) -> T where
    I: IntoIterator<Item = T>,
    I::IntoIter: DoubleEndedIterator<Item = T>, 
[src]

pub fn function_type<I>(arg_type: ArgType, args: I, ret: T) -> T where
    I: IntoIterator<Item = T>,
    I::IntoIter: DoubleEndedIterator<Item = T>, 
[src]

pub fn generic(typ: Generic<Id>) -> T[src]

pub fn skolem(typ: Skolem<Id>) -> T[src]

pub fn variable(typ: TypeVariable) -> T[src]

pub fn alias(name: Id, args: Vec<Generic<Id>>, typ: T) -> T[src]

pub fn alias_implicit(
    name: Id,
    args: Vec<Generic<Id>>,
    typ: T,
    is_implicit: bool
) -> T
[src]

pub fn ident(id: KindedIdent<Id>) -> T[src]

pub fn projection(id: AppVec<Id>) -> T[src]

pub fn function_builtin() -> T[src]

pub fn string() -> T[src]

pub fn char() -> T[src]

pub fn byte() -> T[src]

pub fn int() -> T[src]

pub fn float() -> T[src]

pub fn unit() -> T[src]

impl<Id, T> Type<Id, T> where
    T: TypePtr<Id = Id>, 
[src]

pub fn is_array(&self) -> bool[src]

pub fn as_function(&self) -> Option<(&T, &T)>[src]

pub fn as_explicit_function(&self) -> Option<(&T, &T)>[src]

pub fn as_function_with_type(&self) -> Option<(ArgType, &T, &T)>[src]

pub fn unapplied_args(&self) -> Cow<'_, [T]> where
    T: Clone
[src]

pub fn alias_ident(&self) -> Option<&Id>[src]

pub fn applied_alias(&self) -> Option<&AliasRef<Id, T>>[src]

pub fn is_non_polymorphic_record(&self) -> bool[src]

pub fn params(&self) -> &[Generic<Id>][src]

pub fn kind<'k>(&'k self, cache: &'k KindCache) -> Cow<'k, ArcKind>[src]

impl<T> Type<Symbol, T> where
    T: TypePtr<Id = Symbol>, 
[src]

pub fn name(&self) -> Option<&SymbolRef>[src]

Returns the name of self Example: Option a => Option Int => Int

pub fn owned_name(&self) -> Option<SymbolKey>[src]

Trait Implementations

impl<'ast, Id, T: TypePtr<Id = Id>> AstClone<'ast, Id> for Type<Id, T> where
    Id: AstClone<'ast, Id>,
    T: AstClone<'ast, Id>,
    T::Generics: AstClone<'ast, Id>,
    T::Types: AstClone<'ast, Id>,
    T::Fields: AstClone<'ast, Id>,
    T::TypeFields: AstClone<'ast, Id>,
    Id: Clone
[src]

impl<Id> Borrow<Type<Id, ArcType<Id>>> for ArcType<Id>[src]

impl<Id: Clone, T: Clone + TypePtr<Id = Id>> Clone for Type<Id, T> where
    T::Generics: Clone,
    T::Types: Clone,
    T::Fields: Clone,
    T::TypeFields: Clone
[src]

impl<Id: Debug, T: Debug + TypePtr<Id = Id>> Debug for Type<Id, T> where
    T::Generics: Debug,
    T::Types: Debug,
    T::Fields: Debug,
    T::TypeFields: Debug
[src]

impl<Id, T> Default for Type<Id, T> where
    T: TypePtr<Id = Id>, 
[src]

impl<Id: Eq, T: Eq + TypePtr<Id = Id>> Eq for Type<Id, T> where
    T::Generics: Eq,
    T::Types: Eq,
    T::Fields: Eq,
    T::TypeFields: Eq
[src]

impl<Id> From<Type<Id, ArcType<Id>>> for ArcType<Id> where
    Id: PartialEq
[src]

impl<Id: Hash, T: Hash + TypePtr<Id = Id>> Hash for Type<Id, T> where
    T::Generics: Hash,
    T::Types: Hash,
    T::Fields: Hash,
    T::TypeFields: Hash
[src]

impl<Id: PartialEq, T: PartialEq + TypePtr<Id = Id>> PartialEq<Type<Id, T>> for Type<Id, T> where
    T::Generics: PartialEq,
    T::Types: PartialEq,
    T::Fields: PartialEq,
    T::TypeFields: PartialEq
[src]

impl<Id, T: TypePtr<Id = Id>> StructuralEq for Type<Id, T>[src]

impl<Id, T: TypePtr<Id = Id>> StructuralPartialEq for Type<Id, T>[src]

Auto Trait Implementations

impl<Id, T> RefUnwindSafe for Type<Id, T> where
    Id: RefUnwindSafe,
    T: RefUnwindSafe,
    <T as TypePtr>::Fields: RefUnwindSafe,
    <T as TypePtr>::Generics: RefUnwindSafe,
    <T as TypePtr>::TypeFields: RefUnwindSafe,
    <T as TypePtr>::Types: RefUnwindSafe

impl<Id, T> Send for Type<Id, T> where
    Id: Send + Sync,
    T: Send + Sync,
    <T as TypePtr>::Fields: Send,
    <T as TypePtr>::Generics: Send + Sync,
    <T as TypePtr>::TypeFields: Send,
    <T as TypePtr>::Types: Send

impl<Id, T> Sync for Type<Id, T> where
    Id: Send + Sync,
    T: Send + Sync,
    <T as TypePtr>::Fields: Sync,
    <T as TypePtr>::Generics: Send + Sync,
    <T as TypePtr>::TypeFields: Sync,
    <T as TypePtr>::Types: Sync

impl<Id, T> Unpin for Type<Id, T> where
    Id: Unpin,
    T: Unpin,
    <T as TypePtr>::Fields: Unpin,
    <T as TypePtr>::Generics: Unpin,
    <T as TypePtr>::TypeFields: Unpin,
    <T as TypePtr>::Types: Unpin

impl<Id, T> UnwindSafe for Type<Id, T> where
    Id: RefUnwindSafe + UnwindSafe,
    T: RefUnwindSafe + UnwindSafe,
    <T as TypePtr>::Fields: UnwindSafe,
    <T as TypePtr>::Generics: RefUnwindSafe + UnwindSafe,
    <T as TypePtr>::TypeFields: UnwindSafe,
    <T as TypePtr>::Types: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Id> AsId<Id> for Id where
    Id: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.