Documentation

Batteries.Tactic.DoCommand

The #do command #

The #do command is like run_cmd but allows using variables from previous uses of #do. Furthermore, #do_meta is like #do and shares its variable state while operating in MetaM. Finally, #clear_do can be used to remove all variables from the current do state.

The part of the DoCommandExtensionState used for monad state

Instances For

    The state for #do

    Instances For
      @[reducible, inline]

      Implementation detail of #do

      Equations
      Instances For
        unsafe def Batteries.Tactic.DoCommand.Data.getValue {α : Sort u} (vs : Data) (i : Nat) :
        α

        Implementation detail of #do

        Equations
        Instances For
          unsafe def Batteries.Tactic.DoCommand.Data.getValueLetImpl {α : Sort u} (vs : Data) (i : Nat) (_v : α) :
          α

          Implementation detail of #do

          Equations
          Instances For
            @[reducible, inline, implemented_by Batteries.Tactic.DoCommand.Data.getValueLetImpl]
            unsafe abbrev Batteries.Tactic.DoCommand.Data.getValueLet {α : Sort u} (_vs : Data) (_i : Nat) (v : α) :
            α

            Implementation detail of #do

            Equations
            Instances For
              unsafe def Batteries.Tactic.DoCommand.Data.push {α : Sort u} (d : Data) (x : α) :

              Implementation detail of #do

              Equations
              Instances For
                unsafe def Batteries.Tactic.DoCommand.DoCommandExtensionState.eval (state : DoCommandExtensionState) (α : Type) (type value : Lean.Expr) (checkMeta : Bool := true) (allowSorry : Bool := false) (alternative? : Option String := none) :

                Given value : type which may depend on free variables in state.lctx, evaluates it to a value of type α (assuming type is equivalent to α).

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Implementation detail of #do

                  • newFVars : Array Lean.FVarId

                    All new free variables in the order they are stored in the resulting array

                  • The new state, with updated local context and mutable variables

                  Instances For
                    def Batteries.Tactic.DoCommand.elabDoCommandCore (m : Type → Type) (lift : {α : Type} → m α → MonadStateStack → Lean.Elab.Command.CommandElabM (α × MonadStateStack)) (mExpr : Lean.Expr) (doSeq : Lean.TSyntax `Lean.Parser.Term.doSeq) (allowSorry : Bool) (alternative? : Option String := none) :

                    Monad-generic version of the #do command

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      #do code runs code with access to all variables from previous #do (and #do_meta) invocations. Example:

                      #do let x ← IO.rand 0 100
                      -- these will both print the same number
                      #do IO.println x
                      #do IO.println x
                      

                      This command can be used to run expensive computations once and refer to them later.

                      For #do, the body is run in the CommandElabM monad. For an alternative where computations run in MetaM, use #do_meta.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        An alternative to #do that doesn't check for sorrys

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          #do code runs code with access to all variables from previous #do (and #do_meta) invocations. Example:

                          #do let x ← IO.rand 0 100
                          -- these will both print the same number
                          #do IO.println x
                          #do IO.println x
                          

                          This command can be used to run expensive computations once and refer to them later.

                          For #do, the body is run in the CommandElabM monad. For an alternative where computations run in MetaM, use #do_meta.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            An alternative to #do that doesn't check for sorrys

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              #do_meta code runs code with access to all variables from previous #do and #do_meta invocations in the MetaM monad. Example:

                              #do_meta let x ← IO.rand 0 100
                              -- these will both print the same number
                              #do_meta IO.println x
                              #do_meta IO.println x
                              

                              This command can be used to run expensive computations once and refer to them later.

                              For an alternative where computations run in CommandElabM, use #do.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                An alternative to #do_meta that doesn't check for sorrys

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  #do_meta code runs code with access to all variables from previous #do and #do_meta invocations in the MetaM monad. Example:

                                  #do_meta let x ← IO.rand 0 100
                                  -- these will both print the same number
                                  #do_meta IO.println x
                                  #do_meta IO.println x
                                  

                                  This command can be used to run expensive computations once and refer to them later.

                                  For an alternative where computations run in CommandElabM, use #do.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    An alternative to #do_meta that doesn't check for sorrys

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      Clears all variables from the current #do context.

                                      Equations
                                      Instances For