Types for configuration elaboration #
Class for evaluation of Term syntax directly to a runtime value.
Direct evaluation of
Termsyntax, avoiding term elaboration. Instances should usethrowUnsupportedSyntaxto signal that the syntax is not recognized. Instances shouldn't generally throw other exceptions.Evaluation is allowed to imagine that certain coercions are implicitly inserted. For example, the
Option Intinstance is allowed to recognize1as anOption Inteven though term elaboration would fail here. This allowance should be used lightly, since generallyEvalTermis used as the fast path, and when using theEvalExprbackup, such expressions will no longer be recognized.Implementations should add
TermInfowhen the info is enabled. TheExprreturn value is to support constructing such expressions in combinators.- typeExpr : Expr
A type that can be used when constructing expression for the
TermInfo.
Instances
Equations
Instances For
Class for evaluation of an expression to a runtime value.
Evaluation of an elaborated expression. If the expression is not recognizable, then the instance may throw an exception. They can throw
ConfigEval.throwUnsupportedExprto signal that a generic error should be reported.The provided expression does not contain expression metavariables or
sorry, but level metavariables may be present. We assume these do not affect evaluation. IfexpectedType?is provided, then the expression is coerced as necessary to have this type.The expected type to use when elaborating a term for use with this
EvalExprinstance. If present, the expression will be coerced to this type.
Instances
A view of a Lean.Parser.Term.configItem.
- ref : Syntax
Ref for the entire configuration item
- option : Ident
Ref for the option name itself.
- value : Syntax
The configuration value. Usually this is a
Term, but user-defined configuration items can use arbitrary syntax. For+/-booleans, this syntax is synthetic. Whether this was using
+/-, to be able to give a better error message on type mismatch. It also caches the value so we can skip evaluation forBool, which is a very common case.- origOptionName : Name
The original option name (without macro scopes), even after shifting.
The
optionidentifier split into components, without macro scopes. This allows us to pull off components one at a time if we have hierarchical configuration options.Previous root components of
optionin reverse order, collecting results fromConfigItem.shift.
Instances For
An evaluator for updating a configuration object using configuration items.
This is not a class. In practice, it might be composed out of evaluators or otherwise parameterized in a number of ways.
Evaluates setting the configuration item described by
iteminconfig.