It's impossible for Rust to have sane HKT
2 days ago
- #Rust
- #Lifetimes
- #HKT
- Rust reifies regions as types, using subtyping and variance for lifetime checks.
- Lifetime parameters in data structures complicate type abstraction and variance.
- Abstracting over generic types (HKT) is desired but problematic in Rust due to lifetime reification.
- Lifetimes as first-class types mix technical propositions with business logic, causing abstraction issues.
- Attempts to work around lifetime parameters in traits lead to complex and ugly solutions.
- Higher-kinded types (HKT) in Rust are fundamentally hindered by lifetime reification.
- Variadic kinds could theoretically solve the problem but would make Rust's type system undecidable and complex.
- Generic Associated Types (GATs) do not fully solve the abstraction-over-lifetimes problem.
- Rust's design has a deep category error by conflating lifetimes with business logic types.
- Scala 3's Capture Checking is cited as a better approach to reification.