Type System
A type system assigns types to expressions and catches type errors at compile time, preventing runtime type-related failures.
Purpose
Catch type errors at compile time, providing safety and documentation — the core of statically typed languages.
Mechanism
Typing rules assign types to expressions; the type checker validates them. Strong typing: no implicit unsafe conversions. Static: checked at compile time. Gradual typing (TypeScript) allows dynamic escape hatches. Type inference (Hindley-Milner) derives types automatically.
Use cases
- Compile-time safety
- Type inference
- Language design