Enum gluon_base::types::Type [−][src]
pub enum Type<Id, T = ArcType<Id>> { Hole, Opaque, Builtin(BuiltinType), Forall(Vec<Generic<Id>>, T, Option<Vec<T>>), App(T, AppVec<T>), Function(ArgType, T, T), Record(T), Variant(T), EmptyRow, ExtendRow { types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>, rest: T, }, Ident(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
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
EmptyRow
The empty row, of kind Row
ExtendRow
Row extension, of kind ... -> Row -> Row
Fields of ExtendRow
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 |
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.
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.
Alias(AliasRef<Id, T>)
Skolem(Skolem<Id>)
Methods
impl<Id, T> Type<Id, T>
[src]
impl<Id, T> Type<Id, T>
pub fn as_variable(&self) -> Option<&TypeVariable>
[src]
pub fn as_variable(&self) -> Option<&TypeVariable>
impl<Id, T> Type<Id, T> where
T: From<Type<Id, T>>,
[src]
impl<Id, T> Type<Id, T> where
T: From<Type<Id, T>>,
pub fn hole() -> T
[src]
pub fn hole() -> T
pub fn opaque() -> T
[src]
pub fn opaque() -> T
pub fn builtin(typ: BuiltinType) -> T
[src]
pub fn builtin(typ: BuiltinType) -> T
pub fn forall(params: Vec<Generic<Id>>, typ: T) -> T
[src]
pub fn forall(params: Vec<Generic<Id>>, typ: T) -> T
pub fn forall_with_vars(
params: Vec<Generic<Id>>,
typ: T,
vars: Option<Vec<T>>
) -> T
[src]
pub fn forall_with_vars(
params: Vec<Generic<Id>>,
typ: T,
vars: Option<Vec<T>>
) -> T
pub fn array(typ: T) -> T
[src]
pub fn array(typ: T) -> T
pub fn array_builtin() -> T
[src]
pub fn array_builtin() -> T
pub fn app(id: T, args: AppVec<T>) -> T
[src]
pub fn app(id: T, args: AppVec<T>) -> T
pub fn variant(fields: Vec<Field<Id, T>>) -> T
[src]
pub fn variant(fields: Vec<Field<Id, T>>) -> T
pub fn poly_variant(fields: Vec<Field<Id, T>>, rest: T) -> T
[src]
pub fn poly_variant(fields: Vec<Field<Id, T>>, rest: T) -> T
pub fn tuple<S: ?Sized, I>(symbols: &mut S, elems: I) -> T where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
[src]
pub fn tuple<S: ?Sized, I>(symbols: &mut S, elems: I) -> T where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
pub fn tuple_<S: ?Sized, I>(symbols: &mut S, elems: I) -> Type<Id, T> where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
[src]
pub fn tuple_<S: ?Sized, I>(symbols: &mut S, elems: I) -> Type<Id, T> where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
pub fn record(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>
) -> T
[src]
pub fn record(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>
) -> T
pub fn poly_record(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
[src]
pub fn poly_record(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
pub fn extend_row(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
[src]
pub fn extend_row(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
pub fn empty_row() -> T
[src]
pub fn empty_row() -> T
pub fn function(args: Vec<T>, ret: T) -> T where
T: Clone,
[src]
pub fn function(args: Vec<T>, ret: T) -> T where
T: Clone,
pub fn function_implicit<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>,
pub fn generic(typ: Generic<Id>) -> T
[src]
pub fn generic(typ: Generic<Id>) -> T
pub fn skolem(typ: Skolem<Id>) -> T
[src]
pub fn skolem(typ: Skolem<Id>) -> T
pub fn variable(typ: TypeVariable) -> T
[src]
pub fn variable(typ: TypeVariable) -> T
pub fn alias(name: Id, typ: T) -> T
[src]
pub fn alias(name: Id, typ: T) -> T
pub fn ident(id: Id) -> T
[src]
pub fn ident(id: Id) -> T
pub fn function_builtin() -> T
[src]
pub fn function_builtin() -> T
pub fn string() -> T
[src]
pub fn string() -> T
pub fn char() -> T
[src]
pub fn char() -> T
pub fn byte() -> T
[src]
pub fn byte() -> T
pub fn int() -> T
[src]
pub fn int() -> T
pub fn float() -> T
[src]
pub fn float() -> T
pub fn unit() -> T
[src]
pub fn unit() -> T
impl<Id, T> Type<Id, T> where
T: Deref<Target = Type<Id, T>>,
[src]
impl<Id, T> Type<Id, T> where
T: Deref<Target = Type<Id, T>>,
pub fn as_function(&self) -> Option<(&T, &T)>
[src]
pub fn as_function(&self) -> Option<(&T, &T)>
pub fn as_function_with_type(&self) -> Option<(ArgType, &T, &T)>
[src]
pub fn as_function_with_type(&self) -> Option<(ArgType, &T, &T)>
pub fn unapplied_args(&self) -> Cow<[T]> where
T: Clone,
[src]
pub fn unapplied_args(&self) -> Cow<[T]> where
T: Clone,
pub fn alias_ident(&self) -> Option<&Id>
[src]
pub fn alias_ident(&self) -> Option<&Id>
pub fn is_non_polymorphic_record(&self) -> bool
[src]
pub fn is_non_polymorphic_record(&self) -> bool
pub fn params(&self) -> &[Generic<Id>]
[src]
pub fn params(&self) -> &[Generic<Id>]
pub fn kind(&self) -> Cow<ArcKind>
[src]
pub fn kind(&self) -> Cow<ArcKind>
impl<T> Type<Symbol, T> where
T: Deref<Target = Type<Symbol, T>>,
[src]
impl<T> Type<Symbol, T> where
T: Deref<Target = Type<Symbol, T>>,
pub fn name(&self) -> Option<&SymbolRef>
[src]
pub fn name(&self) -> Option<&SymbolRef>
Returns the name of self
Example:
Option a => Option
Int => Int
Trait Implementations
impl<Id> From<Type<Id, AstType<Id>>> for AstType<Id>
[src]
impl<Id> From<Type<Id, AstType<Id>>> for AstType<Id>
impl<Id: Clone, T: Clone> Clone for Type<Id, T>
[src]
impl<Id: Clone, T: Clone> Clone for Type<Id, T>
fn clone(&self) -> Type<Id, T>
[src]
fn clone(&self) -> Type<Id, T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<Id: Debug, T: Debug> Debug for Type<Id, T>
[src]
impl<Id: Debug, T: Debug> Debug for Type<Id, T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<Id: Eq, T: Eq> Eq for Type<Id, T>
[src]
impl<Id: Eq, T: Eq> Eq for Type<Id, T>
impl<Id: PartialEq, T: PartialEq> PartialEq for Type<Id, T>
[src]
impl<Id: PartialEq, T: PartialEq> PartialEq for Type<Id, T>
fn eq(&self, other: &Type<Id, T>) -> bool
[src]
fn eq(&self, other: &Type<Id, T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Type<Id, T>) -> bool
[src]
fn ne(&self, other: &Type<Id, T>) -> bool
This method tests for !=
.
impl<Id: Hash, T: Hash> Hash for Type<Id, T>
[src]
impl<Id: Hash, T: Hash> Hash for Type<Id, T>
fn hash<__HIdT: Hasher>(&self, state: &mut __HIdT)
[src]
fn hash<__HIdT: Hasher>(&self, state: &mut __HIdT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<Id> From<Type<Id, ArcType<Id>>> for ArcType<Id>
[src]
impl<Id> From<Type<Id, ArcType<Id>>> for ArcType<Id>