Enum gluon_base::types::Type
[−]
[src]
pub enum Type<Id, T = ASTType<Id>> { App(T, T), Data(T, Vec<T>), Variants(Vec<(Id, T)>), Variable(TypeVariable), Generic(Generic<Id>), Function(Vec<T>, T), Builtin(BuiltinType), Array(T), Record { types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>, }, Id(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
App(T, T)
An application which applies the first argument on the second.
Option Int
would be represented as App(Option, Int)
Data(T, Vec<T>)
An application with multiple arguments
Variants(Vec<(Id, T)>)
A variant type | A Int Float | B
.
The second element of the tuple is the function type which the constructor has which in the
above example means that A's type is Int -> Float -> A
and B's is B
Variable(TypeVariable)
Representation for type variables
Generic(Generic<Id>)
Variant for "generic" variables. These occur in signatures as lowercase identifers a
, b
etc and are what unbound type variables are eventually made into.
Function(Vec<T>, T)
A function type <type> -> <type>
Builtin(BuiltinType)
A builtin type
Array(T)
An array type Array T
Record
A record type
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 |
Id(Id)
An identifier type. Anything which is not a builting type.
Alias(AliasData<Id, T>)
Methods
impl<Id, T> Type<Id, T> where T: Deref<Target=Type<Id, T>>
[src]
fn is_uninitialized(&self) -> bool
fn kind(&self) -> RcKind
impl<Id, T> Type<Id, T> where T: From<Type<Id, T>>
[src]
fn app(l: T, r: T) -> T
fn array(typ: T) -> T
fn data(id: T, args: Vec<T>) -> T
fn variants(vs: Vec<(Id, T)>) -> T
fn record(types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>) -> T
fn function(args: Vec<T>, ret: T) -> T
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 id(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]
Trait Implementations
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.
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: Eq, T: Eq> Eq for Type<Id, T>
[src]
impl<Id: Debug, T: Debug> Debug for Type<Id, T>
[src]
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