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
Row extension, of kind ... -> Row -> Row
Ident(Id)
An identifier type. These are created during parsing, but should all be
resolved into Type::Alias
es 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::Generic
s during generalization.
Generic(Generic<Id>)
A variable that needs to be instantiated with a fresh type variable when the binding is referred to.