Enum gluon_base::types::Type
[−]
[src]
pub enum Type<Id, T = ArcType<Id>> { Hole, Opaque, Builtin(BuiltinType), App(T, Vec<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(AliasData<Id, T>), }
The representation of gluon's types.
For efficency 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
App(T, Vec<T>)
A type application with multiple arguments. For example,
Map String Int
would be represented as App(Map, [String, Int])
.
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
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 refered to.
Alias(AliasData<Id, T>)
Methods
impl<Id, T> Type<Id, T> where T: From<Type<Id, T>>
[src]
fn hole() -> T
fn opaque() -> T
fn array(typ: T) -> T
fn app(id: T, args: Vec<T>) -> T
fn variant(fields: Vec<Field<Id, T>>) -> T
fn poly_variant(fields: Vec<Field<Id, T>>, rest: T) -> T
fn record(types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>) -> T
fn poly_record(types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T)
-> T
fields: Vec<Field<Id, T>>,
rest: T)
-> T
fn extend_row(types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T)
-> T
fields: Vec<Field<Id, T>>,
rest: T)
-> T
fn empty_row() -> T
fn function(args: Vec<T>, ret: T) -> T where T: Clone
fn generic(typ: Generic<Id>) -> T
fn builtin(typ: BuiltinType) -> T
fn variable(typ: TypeVariable) -> T
fn alias(name: Id, args: Vec<Generic<Id>>, typ: T) -> T
fn ident(id: Id) -> T
fn string() -> T
fn char() -> T
fn byte() -> T
fn int() -> T
fn float() -> T
fn unit() -> T
impl<Id, T> Type<Id, T> where T: Deref<Target=Type<Id, T>>
[src]
impl<T> Type<Symbol, T> where T: Deref<Target=Type<Symbol, T>>
[src]
fn name(&self) -> Option<&SymbolRef>
Returns the name of self
Example:
Option a => Option
Int => Int
Trait Implementations
impl<Id: Clone, T: Clone> Clone for 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
Performs copy-assignment from source
. Read more
impl<Id: Debug, T: Debug> Debug for Type<Id, T>
[src]
impl<Id: Eq, T: Eq> Eq for Type<Id, T>
[src]
impl<Id: PartialEq, T: PartialEq> PartialEq for Type<Id, T>
[src]
fn eq(&self, __arg_0: &Type<Id, T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Type<Id, T>) -> bool
This method tests for !=
.
impl<Id: Hash, T: Hash> Hash for Type<Id, T>
[src]
fn hash<__HIdT: Hasher>(&self, __arg_0: &mut __HIdT)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.