pub struct Scheme {
pub vars: Vec<TyVarId>,
pub row_vars: Vec<RowVarId>,
pub params: Vec<Arc<str>>,
pub ty: Ty,
}Expand description
A type scheme: forall vars rows. ty. Let-polymorphism over both dimensions, which is what
§3.2 means by “effect polymorphism is what keeps one standard library”.
Fields§
§vars: Vec<TyVarId>§row_vars: Vec<RowVarId>§params: Vec<Arc<str>>The named type parameters of a user-written def map[T, U](…).
A prelude scheme quantifies over numbered variables because nobody reads its source; a
user’s quantifies over names, because the name is what the programmer wrote, what the body
is checked against, what a diagnostic has to print, and what beck iface publishes. Inside
the body each of these is a rigid Ty::Con(name, []) — an opaque type that unifies with
itself and nothing else, which is exactly the property that makes the definition honest
about being polymorphic. Subst::instantiate turns them back into fresh variables at
every call site. docs/32 §32.7.
ty: Ty