eval::run

eval/src/run.mo

typeEvalStage#
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.

structEvalOptions#
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
}
structEvalTarget#
pub struct EvalTarget {
    root : String, // "main", or the REPL's "__repl_expr_<n>"
    context_path : ModulePath // the lowerer's root module
}
structEvalCheck#
pub struct EvalCheck {
    errors : List String,
    warnings : List String
}
structEvalFailure#
pub struct EvalFailure {
    stage : EvalStage,
    message : String,
    eval_error : Option CoreEvalError,
    warnings : List String
}
structEvalSuccess#
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
}
structEvalBenchProgram#
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.

defEval.check_elaborated#
pub def Eval.check_elaborated (em : ElaboratedModules) (affine : AffineMode)
(label : String) (verbose : Bool) : IO EvalCheck

Typecheck 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.

defEval.run_elaborated#
pub def Eval.run_elaborated (em : ElaboratedModules) (o : EvalOptions)
(t : EvalTarget) : IO (Result EvalFailure EvalSuccess)
defEval.lower_elaborated_for_bench#
pub def Eval.lower_elaborated_for_bench (em : ElaboratedModules) (root : String)
(context_path : ModulePath) : Result String EvalBenchProgram

The same pre-evaluation half, for a benchmark that times evaluation alone; failures are reduced to their rendered message.

defEval.type_of#
pub def Eval.type_of (em : ElaboratedModules) (o : EvalOptions) (t : EvalTarget)
: IO (Result EvalFailure String)
defEval.run_sources#
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.