eval::run
eval/src/run.mo
pub type EvalStage {
eval_stage_load,
eval_stage_entry_missing,
eval_stage_entry_params,
eval_stage_typecheck,
eval_stage_elaborate,
eval_stage_lower,
eval_stage_eval,
}Where a failure stopped. entry_missing/entry_params exist only for
require_entry callers (/try and the REPL); monad eval lets a missing
main surface as a lower-stage error, exactly as it always has.
pub struct EvalOptions {
fuel : I64, // -1 unlimited
depth_limit : I64, // -1 unlimited
affine : AffineMode,
label : String, // diagnostics path ("scratchpad.mo", "repl.mo", ...)
verbose : Bool,
want_type : Bool, // compute the type-directed value/type renderings
require_entry : Bool // friendly no-entry / parameter errors
}pub struct EvalTarget {
root : String, // "main", or the REPL's "__repl_expr_<n>"
context_path : ModulePath // the lowerer's root module
}pub struct EvalCheck {
errors : List String,
warnings : List String
}pub struct EvalFailure {
stage : EvalStage,
message : String,
eval_error : Option CoreEvalError,
warnings : List String
}pub struct EvalSuccess {
value_text : String, // format_value (want_type only)
type_text : String, // format_type (want_type only)
debug_text : String, // show_value_debug
warnings : List String
}pub struct EvalBenchProgram {
ir : CoreIr,
globals : GlobalTable
}A lowered root plus the global table it references -- the
pre-evaluation half of Eval.run_elaborated. Exposed so a benchmark can
time lang::core_eval.eval alone, with parse/elaborate/lower amortized
out (bench/src/core_eval_bench.mo). Never called from
Eval.run_sources, so the wasm engine does not carry it.
pub def Eval.check_elaborated (em : ElaboratedModules) (affine : AffineMode)
(label : String) (verbose : Bool) : IO EvalCheckTypecheck the target module. Split out because the REPL's declaration step needs exactly this (no lowering, no evaluation) to decide whether an entry joins the session.
pub def Eval.run_elaborated (em : ElaboratedModules) (o : EvalOptions)
(t : EvalTarget) : IO (Result EvalFailure EvalSuccess)pub def Eval.lower_elaborated_for_bench (em : ElaboratedModules) (root : String)
(context_path : ModulePath) : Result String EvalBenchProgramThe same pre-evaluation half, for a benchmark that times evaluation alone; failures are reduced to their rendered message.
pub def Eval.type_of (em : ElaboratedModules) (o : EvalOptions) (t : EvalTarget)
: IO (Result EvalFailure String)pub def Eval.run_sources (main : ModuleInfo) (seeds : List ModulePath)
(sources : List ModuleSource) (reject : ModulePath -> Option String)
(o : EvalOptions) (t : EvalTarget) : IO (Result EvalFailure EvalSuccess)The whole pipeline for a module set the caller already holds: the
standard source-list loader, the pure elaboration, then the shared
recipe. This is what /try calls; monad eval uses Eval.run_file.