Documentation

Lean.Elab.Do.Control

Instances For
    def Lean.Elab.Do.ControlStack.stateT (baseMonadInfo : MonadInfo) (muts : Array MutVar) (σ : Expr) (base : ControlStack) :
    Instances For
      def Lean.Elab.Do.ControlStack.optionT (baseMonadInfo : MonadInfo) (optionTWrapper casesOnWrapper : Name) (getCont : DoElabM (DoElabM Expr)) (base : ControlStack) :
      Instances For
        def Lean.Elab.Do.ControlStack.exceptT (baseMonadInfo : MonadInfo) (exceptTWrapper casesOnWrapper : Name) (getCont : DoElabM ReturnCont) (ε : Expr) (base : ControlStack) :
        Instances For
          Instances For
            Instances For

              Plan for embedding a non-tail-resumptive body inside origCont via a monad-transformer stack.

              • origCont : DoElemCont

                Continuation of the surrounding do block; restored after the body.

              • returnBase? : Option ControlStack

                Substack at which the early-return handler was installed, if any.

              • breakBase? : Option ControlStack

                Substack at which the break handler was installed, if any.

              • continueBase? : Option ControlStack

                Substack at which the continue handler was installed, if any.

              • liftedStack : ControlStack

                The full transformer stack over the base monad.

              • liftedDoBlockResultType : Expr

                The body's elaboration type, stM dec.resultType.

              Instances For

                Build the lifter plan for a body whose effects are summarised by info.

                Instances For

                  Elaborate elabElem in the lifted stack: install break/continue/return handlers funnelling into liftedStack and set the doBlock result type to liftedDoBlockResultType. Semantically MonadControl.liftWith fun runInBase => elabElem (runInBase pure). Conts passed to elabElem are implicitly wrapped in runInBase, realised later by ControlStack.mkBreak/mkContinue/mkReturn once the transformer stack t is fixed by aggregating effects across all lift sites for this lifter.

                  Instances For

                    Build a DoElemCont that unpacks the lifted body's result and resumes origCont.k.

                    Instances For