#[non_exhaustive]pub enum Discipline {
Dynamic,
Gradual,
StaticExplicit,
StaticInferred,
Hm,
}Expand description
How much a language checks statically, and how much it infers.
| Discipline | Like | Static checking | Inference |
|---|---|---|---|
Dynamic | Python, Lua, Mox | Only statically certain arity and shape errors | none: every value is any |
Gradual | TypeScript, Mercury | Where annotated; any at the boundaries | local |
StaticExplicit | C, Go, Zero | Everything | let initializers, literals, generic arguments |
StaticInferred | Kraken, Iron | Everything | bidirectional: also closure signatures from context |
Hm | ML family | Everything | full, with let-polymorphism |
Both static disciplines check generic items, interfaces (traits), impl
blocks, associated types, and dyn/impl Trait types: any HIR that uses
them needs them. StaticInferred additionally infers unannotated closure
parameters and results from the expected function type, or from use.
Implemented in 0.3.0: Dynamic, StaticExplicit, and StaticInferred.
Gradual and Hm are designed (see the crate’s dev/ROADMAP.md) and
land in 0.5.0; checking under them returns
CheckError::NotImplemented.
§Examples
use typeck_lang::Discipline;
assert!(Discipline::Dynamic.is_implemented());
assert!(Discipline::StaticInferred.is_implemented());
assert!(!Discipline::Hm.is_implemented());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Dynamic
No static type errors; every value has type any.
Gradual
Checked where annotated; unannotated values are any.
StaticExplicit
Declared types on signatures and globals; local inference for let.
StaticInferred
Bidirectional local inference, generics, traits or interfaces.
Hm
Hindley-Milner: full inference with let-polymorphism.
Implementations§
Source§impl Discipline
impl Discipline
Sourcepub const fn is_implemented(self) -> bool
pub const fn is_implemented(self) -> bool
Whether this version of the checker implements the discipline.
§Examples
use typeck_lang::Discipline;
assert!(Discipline::StaticExplicit.is_implemented());
assert!(!Discipline::Gradual.is_implemented());