Enum gluon_base::types::Type
[−]
[src]
pub enum Type<Id, T = ArcType<Id>> { Hole, Opaque, Builtin(BuiltinType), App(T, AppVec<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>), }
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, AppVec<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 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 refered to.
Alias(AliasRef<Id, T>)
Methods
impl<Id, T> Type<Id, T> where
T: From<Type<Id, T>>,
[src]
T: From<Type<Id, T>>,
fn hole() -> T
[src]
fn opaque() -> T
[src]
fn array(typ: T) -> T
[src]
fn array_builtin() -> T
[src]
fn app(id: T, args: AppVec<T>) -> T
[src]
fn variant(fields: Vec<Field<Id, T>>) -> T
[src]
fn poly_variant(fields: Vec<Field<Id, T>>, rest: T) -> T
[src]
fn tuple<S: ?Sized, I>(symbols: &mut S, elems: I) -> T where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
[src]
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
fn tuple_<S: ?Sized, I>(symbols: &mut S, elems: I) -> Type<Id, T> where
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
[src]
S: IdentEnv<Ident = Id>,
I: IntoIterator<Item = T>,
fn record(types: Vec<Field<Id, Alias<Id, T>>>, fields: Vec<Field<Id, T>>) -> T
[src]
fn poly_record(
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
[src]
types: Vec<Field<Id, Alias<Id, 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
[src]
types: Vec<Field<Id, Alias<Id, T>>>,
fields: Vec<Field<Id, T>>,
rest: T
) -> T
fn empty_row() -> T
[src]
fn function(args: Vec<T>, ret: T) -> T where
T: Clone,
[src]
T: Clone,
fn generic(typ: Generic<Id>) -> T
[src]
fn builtin(typ: BuiltinType) -> T
[src]
fn variable(typ: TypeVariable) -> T
[src]
fn alias(name: Id, args: Vec<Generic<Id>>, typ: T) -> T
[src]
fn ident(id: Id) -> T
[src]
fn function_builtin() -> T
[src]
fn string() -> T
[src]
fn char() -> T
[src]
fn byte() -> T
[src]
fn int() -> T
[src]
fn float() -> T
[src]
fn unit() -> T
[src]
impl<Id, T> Type<Id, T> where
T: Deref<Target = Type<Id, T>>,
[src]
T: Deref<Target = Type<Id, T>>,
fn as_function(&self) -> Option<(&T, &T)>
[src]
fn unapplied_args(&self) -> &[T]
[src]
fn alias_ident(&self) -> Option<&Id>
[src]
fn is_non_polymorphic_record(&self) -> bool
[src]
impl<T> Type<Symbol, T> where
T: Deref<Target = Type<Symbol, T>>,
[src]
T: Deref<Target = Type<Symbol, T>>,
fn name(&self) -> Option<&SymbolRef>
[src]
Returns the name of self
Example:
Option a => Option
Int => Int
fn kind(&self) -> Cow<ArcKind>
[src]
Trait Implementations
impl<Id: Clone, T: Clone> Clone for Type<Id, T>
[src]
fn clone(&self) -> Type<Id, T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
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
[src]
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
[src]
This method tests for !=
.