"do" Unchained: Embracing Local Imperativity in a Purely Functional Langua...
summary
Adds local mutation, early return and iteration to do notation and provides formal translation rules that compile them to pure code while preserving semantics and complexity. Implements the translation as a Lean 4 macro expander and an intrinsic embedding into monads, models each feature as a separate effect such as an exception transformer and state transformer, and proves in Lean that the generated monadic term is equivalent to an interpreter for any LawfulMonad. Artifacts and proofs are available and the features are already used in Lean 4 codebases.
AI-written summary · about
