Enum gluon_base::types::Type

source ·
pub enum Type<Id, T = ArcType<Id>> {
Show 18 variants Hole, Opaque, Error, Builtin(BuiltinType), Forall(Vec<Generic<Id>>, T, Option<Vec<T>>), App(T, AppVec<T>), Function(ArgType, T, T), Record(T), Variant(T), Effect(T), EmptyRow, ExtendRow { types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>, rest: T, }, Ident(Id), Projection(AppVec<Id>), Variable(TypeVariable), Generic(Generic<Id>), Alias(AliasRef<Id, T>), Skolem(Skolem<Id>),
}
Expand description

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(Vec<Generic<Id>>, T, Option<Vec<T>>)

Universally quantified types

App(T, AppVec<T>)

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

Fields

types: Vec<Field<Id, Alias<Id, T>>>

The associated types of this record type

fields: Vec<Field<Id, T>>

The fields of this record type

rest: T

The rest of the row

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

Ident(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

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.