RustConf 2023 - Extending Rust's Effect System

Explore the design space of effect generics in Rust, including effect aliases, carried effects, and effect types, to solve effect mismatches and integrate the effect system in Rust.

Key takeaways
  • Effect mismatches are present in almost every trait in the standard library.
  • There are five effects currently in Rust: async, unsafe, const, try, and generators.
  • Effect generics allow us to be generic over effects, enabling us to write functions that take different effects as inputs.
  • When trying to implement effect generics, we must consider the desugaring of effects into types in the type system.
  • Effects can lead to an exponential explosion of APIs, similar to the function coloring problem.
  • The effect system is everywhere in Rust, but it is not straightforward to integrate.
  • Effect generics can be used to solve effect mismatches by providing a way to detect and compose effects.
  • The design space for effect generics includes effect aliases, carried effects, and effect types.
  • Carried effects are those that are propagated through the call chain, and can be used to implement things like compile-time evaluation.
  • Effect types are those that are desugared into actual types in the type system, such as async or const.
  • The RustEffects initiative is working on formalizing the effect generics work and providing a way to name specific sets of effects.