Documentation

Lean.Elab.ConfigEval.Basic

Basic interface for configuration evaluation #

Instances For

    Evaluate stx using either evalExpr.

    Instances For

      Evaluate stx using either evalStx or evalExpr.

      Instances For
        @[inline]
        def Lean.Elab.ConfigEval.EvalTerm.evalTermWithInfo {α : Type} (expectedType? : Option Expr) (f : TermTermElabM (α × Expr)) (stx : Term) :
        Instances For
          @[inline]

          Like evalTermWithInfo, but uses an existing ToExpr instance for expectedType? and for constructing the expression.

          Instances For
            def Lean.Elab.ConfigEval.EvalExpr.withWHNF {α : Type} (f : ExprMetaM α) (e : Expr) (errMsg : MessageData) :

            Evaluates f e, and if that does throwUnsupportedExpr, evaluates f (← whnf e). If either throw another exception, aborts immediately with that exception. If both do throwUnsupportedExpr, then this generates an exception.

            Instances For

              Gets the current name of the option after any shifting. For example, if an option is named a.b.c.d and there is a handler for a.b.*, then the handler receives a ConfigItem whose current option name is c.d.

              Instances For

                Drops the first component of the optionName, returning the new config item. The first component is stored at the front of prevOptionComps.

                Instances For
                  @[specialize #[]]
                  partial def Lean.Elab.ConfigEval.foldConfigM {α : Type} {m : TypeType} [Monad m] [MonadRef m] (init : α) (cfg : Syntax) (k : αConfigItemm α) (onErr : αSyntaxm α) :
                  m α

                  Interprets cfg as configuration item or list of configuration items.

                  Items are interpreted in a way that allows user-defined configurations. Nearly anything that looks like configuration items or lists of configuration items will be interpreted. We're expecting an item that has one of the following formats:

                  • "(" ident/atom ":=" syntax ")"
                  • "+" ident/atom
                  • "-" ident/atom

                  The specification:

                  • A null node is a list of configurations
                  • A one-argument node is considered to be a wrapper like optConfig or configItem.
                  • A node with at two arguments starting with a "+"/"-" atom and whose second argument is an ident or atom is a posConfigItem/negConfigItem
                  • A node with at most five arguments starting with a "(" atom and whose second argument is an ident or atom is a valConfigItem. The fourth argument is the value, and it is allowed to have arbitary syntax (it does not need to be a Term).
                  • A bare atom is considered to be a "+" option.

                  We trust that any atoms are valid as idents. The atom will be parsed using String.toName to form the name. (Small optimization: if the name doesn't contain ., we use Name.mkSimple to skip parsing. Atoms must not contain numerals or «» escapes.)

                  On interpretation error, onErr is called with the current configuration object and the offending syntax item. It may process the item itself or otherwise throw an error. We leave it to onErr to decide what to do for items containing Syntax.missing.

                  @[specialize #[]]
                  partial def Lean.Elab.ConfigEval.foldConfigsM {α : Type} {m : TypeType} [Monad m] [MonadRef m] (init : α) (cfgs : Array Syntax) (k : αConfigItemm α) (onErr : αSyntaxm α) :
                  m α

                  Like foldConfigM but takes an array of configurations or configuration items.

                  def Lean.Elab.ConfigEval.EvalConfigItem.trySet {α : Type} (eval : EvalConfigItem α) (config : α) (item : ConfigItem) (logExceptions : Bool) :
                  Instances For
                    def Lean.Elab.ConfigEval.EvalConfigItem.defaultOnErr {α : Type} (cfg : α) (cfgItem : Syntax) (cfgType? : Option Expr := none) :

                    Default onErr handler. If the cfgItem contains .missing, we assume an error has already been reported by the parser and return cfg. Otherwise, we throw an unsupported syntax exception.

                    If cfgType? is present, then it adds completion info when the identifier is missing.

                    Instances For
                      def Lean.Elab.ConfigEval.EvalConfigItem.setConfig {α : Type} (eval : EvalConfigItem α) (init : α) (cfg : Syntax) (onErr : αSyntaxTermElabM α := fun (cfg : α) (cfgItem : Syntax) => defaultOnErr cfg cfgItem) (logExceptions : Bool := false) :

                      Applies the configuration cfg to init using eval.set. If logExceptions is true, then catches and logs exceptions.

                      The onErr callback is used for invalid configuration syntax.

                      Note: this should be run from within runConfigElab.

                      Instances For
                        def Lean.Elab.ConfigEval.EvalConfigItem.setConfigs {α : Type} (eval : EvalConfigItem α) (init : α) (cfgs : Array Syntax) (onErr : αSyntaxTermElabM α := fun (cfg : α) (cfgItem : Syntax) => defaultOnErr cfg cfgItem) (logExceptions : Bool := false) :

                        Applies the configuration cfg to init using eval.set. If logExceptions is true, then catches and logs exceptions.

                        The onErr callback is used for invalid configuration syntax.

                        Note: this should be run from within runConfigElab.

                        Instances For

                          Runs mx using a fresh meta and term state. This should be used around any configuration elaboration.

                          Instances For
                            def Lean.Elab.ConfigEval.EvalConfigItem.setConfig' {α : Type} (eval : EvalConfigItem α) (init : α) (cfg : Syntax) (onErr : αSyntaxTermElabM α := fun (cfg : α) (cfgItem : Syntax) => defaultOnErr cfg cfgItem) (logExceptions : Bool := false) :

                            Calls EvalConfigItem.setConfig' from within runConfigElab.

                            Instances For
                              def Lean.Elab.ConfigEval.EvalConfigItem.setConfigs' {α : Type} (eval : EvalConfigItem α) (init : α) (cfgs : Array Syntax) (onErr : αSyntaxTermElabM α := fun (cfg : α) (cfgItem : Syntax) => defaultOnErr cfg cfgItem) (logExceptions : Bool := false) :

                              Calls EvalConfigItem.setConfigs' from within runConfigElab.

                              Instances For