Enum gluon_base::types::Type
source · pub enum Type<Id, T: TypePtr<Id = Id> = ArcType<Id>> {
Show 19 variants
Hole,
Opaque,
Error,
Builtin(BuiltinType),
Forall(T::Generics, T),
App(T, T::Types),
Function(ArgType, T, T),
Record(T),
Variant(T),
Effect(T),
EmptyRow,
ExtendRow {
fields: T::Fields,
rest: T,
},
ExtendTypeRow {
types: T::TypeFields,
rest: T,
},
Ident(KindedIdent<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(T::Generics, T)
Universally quantified types
App(T, T::Types)
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
Row extension, of kind ... -> Row -> Row
ExtendTypeRow
Row extension, of kind ... -> Row -> Row
Ident(KindedIdent<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.
Alias(AliasRef<Id, T>)
Skolem(Skolem<Id>)
Implementations§
source§impl<Id, T> Type<Id, T>where
T: TypePtr<Id = Id>,
impl<Id, T> Type<Id, T>where
T: TypePtr<Id = Id>,
pub fn as_variable(&self) -> Option<&TypeVariable>
source§impl<Id, T> Type<Id, T>
impl<Id, T> Type<Id, T>
pub fn hole() -> T
pub fn opaque() -> T
pub fn error() -> T
pub fn builtin(typ: BuiltinType) -> T
pub fn forall(params: Vec<Generic<Id>>, typ: T) -> T
pub fn array(typ: T) -> T
pub fn array_builtin() -> T
pub fn app(id: T, args: T::Types) -> T
pub fn variant(fields: Vec<Field<T::SpannedId, T>>) -> T
pub fn poly_variant(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T
pub fn effect(fields: Vec<Field<T::SpannedId, T>>) -> T
pub fn poly_effect(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T
pub fn tuple<S, I>(symbols: &mut S, elems: I) -> T
pub fn tuple_<S, I>(symbols: &mut S, elems: I) -> Type<Id, T>
pub fn record( types: Vec<Field<T::SpannedId, Alias<Id, T>>>, fields: Vec<Field<T::SpannedId, T>> ) -> T
pub fn poly_record( types: Vec<Field<T::SpannedId, Alias<Id, T>>>, fields: Vec<Field<T::SpannedId, T>>, rest: T ) -> T
pub fn extend_full_row( types: Vec<Field<T::SpannedId, Alias<Id, T>>>, fields: Vec<Field<T::SpannedId, T>>, rest: T ) -> T
pub fn extend_row(fields: Vec<Field<T::SpannedId, T>>, rest: T) -> T
pub fn extend_type_row( types: Vec<Field<T::SpannedId, Alias<Id, T>>>, rest: T ) -> T
pub fn empty_row() -> T
pub fn function<I>(args: I, ret: T) -> T
pub fn function_implicit<I>(args: I, ret: T) -> T
pub fn function_type<I>(arg_type: ArgType, args: I, ret: T) -> T
pub fn generic(typ: Generic<Id>) -> T
pub fn skolem(typ: Skolem<Id>) -> T
pub fn variable(typ: TypeVariable) -> T
pub fn alias(name: Id, args: Vec<Generic<Id>>, typ: T) -> T
pub fn alias_implicit( name: Id, args: Vec<Generic<Id>>, typ: T, is_implicit: bool ) -> T
pub fn ident(id: KindedIdent<Id>) -> T
pub fn projection(id: AppVec<Id>) -> T
pub fn function_builtin() -> T
pub fn string() -> T
pub fn char() -> T
pub fn byte() -> T
pub fn int() -> T
pub fn float() -> T
pub fn unit() -> T
source§impl<Id, T> Type<Id, T>where
T: TypePtr<Id = Id>,
impl<Id, T> Type<Id, T>where
T: TypePtr<Id = Id>,
pub fn is_array(&self) -> bool
pub fn as_function(&self) -> Option<(&T, &T)>
pub fn as_explicit_function(&self) -> Option<(&T, &T)>
pub fn as_function_with_type(&self) -> Option<(ArgType, &T, &T)>
pub fn unapplied_args(&self) -> Cow<'_, [T]>where
T: Clone,
pub fn alias_ident(&self) -> Option<&Id>
pub fn applied_alias(&self) -> Option<&AliasRef<Id, T>>
pub fn is_non_polymorphic_record(&self) -> bool
pub fn params(&self) -> &[Generic<Id>]
pub fn kind<'k>(&'k self, cache: &'k KindCache) -> Cow<'k, ArcKind>
Trait Implementations§
source§impl<'de, Id, T> DeserializeState<'de, Seed<Id, T>> for Type<Id, T>where
T: Clone + TypePtr<Id = Id> + From<Type<Id, T>> + Any + DeserializeState<'de, Seed<Id, T>>,
T::Types: Default + Extend<T>,
T::Generics: Default + Extend<Generic<Id>> + Clone,
T::Fields: DeserializeState<'de, Seed<Id, T>>,
T::TypeFields: DeserializeState<'de, Seed<Id, T>>,
Id: DeserializeState<'de, Seed<Id, T>> + Clone + Any,
impl<'de, Id, T> DeserializeState<'de, Seed<Id, T>> for Type<Id, T>where
T: Clone + TypePtr<Id = Id> + From<Type<Id, T>> + Any + DeserializeState<'de, Seed<Id, T>>,
T::Types: Default + Extend<T>,
T::Generics: Default + Extend<Generic<Id>> + Clone,
T::Fields: DeserializeState<'de, Seed<Id, T>>,
T::TypeFields: DeserializeState<'de, Seed<Id, T>>,
Id: DeserializeState<'de, Seed<Id, T>> + Clone + Any,
source§fn deserialize_state<__D>(
__seed: &mut Seed<Id, T>,
__deserializer: __D
) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize_state<__D>(
__seed: &mut Seed<Id, T>,
__deserializer: __D
) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Self
using seed
and the deserializer
source§impl<Id: PartialEq, T: PartialEq + TypePtr<Id = Id>> PartialEq for Type<Id, T>
impl<Id: PartialEq, T: PartialEq + TypePtr<Id = Id>> PartialEq for Type<Id, T>
source§impl<Id, T> SerializeState<SeSeed> for Type<Id, T>where
T: TypePtr<Id = Id> + SerializeState<SeSeed>,
Id: SerializeState<SeSeed>,
T::Fields: SerializeState<SeSeed>,
T::TypeFields: SerializeState<SeSeed>,
impl<Id, T> SerializeState<SeSeed> for Type<Id, T>where
T: TypePtr<Id = Id> + SerializeState<SeSeed>,
Id: SerializeState<SeSeed>,
T::Fields: SerializeState<SeSeed>,
T::TypeFields: SerializeState<SeSeed>,
source§fn serialize_state<__S>(
&self,
__serializer: __S,
__seed: &SeSeed
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
fn serialize_state<__S>(
&self,
__serializer: __S,
__seed: &SeSeed
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
self