girard/types
The public type vocabulary girard reports: the inferred Type model and the
Error describing why a module could not be typed. The inference engine and
its helpers are implementation detail and live under girard/internal/*.
Types
Why a module could not be typed. Variants describe the failure in terms of the type system and the offending source construct.
pub type Error {
TypeMismatch(left: Type, right: Type)
ArityMismatch
RecursiveType(id: Int, type_: Type)
UnboundVariable(name: String)
UnknownConstructor(name: String)
UnknownModule(alias: String)
NoSuchExport(module: String, name: String)
NoSuchField(type_name: String, label: String)
NotARecord
NotATuple
TupleIndexOutOfRange(index: Int)
UnknownLabel(label: String)
AmbiguousCall
MissingArgument
Unsupported(feature: String)
ParseFailed(glance.Error)
}
Constructors
-
-
ArityMismatch -
RecursiveType(id: Int, type_: Type) -
UnboundVariable(name: String) -
UnknownConstructor(name: String) -
UnknownModule(alias: String) -
NoSuchExport(module: String, name: String) -
NoSuchField(type_name: String, label: String) -
NotARecord -
NotATuple -
TupleIndexOutOfRange(index: Int) -
UnknownLabel(label: String) -
AmbiguousCall -
MissingArgument -
Unsupported(feature: String) -
ParseFailed(glance.Error)
A polymorphic type scheme forall vars. type_: the generalized type of a
top-level function or constant. vars are the ids of the Vars in type_
that are universally quantified (generic); a monomorphic binding is
Scheme([], type_).
pub type Scheme {
Scheme(vars: List(Int), type_: Type)
}
Constructors
-
Scheme(vars: List(Int), type_: Type)
pub type Type {
Named(module: String, name: String, arguments: List(Type))
Fn(arguments: List(Type), return: Type)
Var(id: Int)
Tuple(elements: List(Type))
}
Constructors
-
Named(module: String, name: String, arguments: List(Type))A named, nominal type such as
Int,List(a),Result(a, e)or a user-defined custom type.moduleis"gleam"for prelude types. -
A function type
fn(a, b) -> c. -
Var(id: Int)A type variable. Its state (unbound / bound / generic) lives in the substitution table keyed by
idduring inference. -
Tuple(elements: List(Type))A tuple type
#(a, b, c).