gsh/evaluator/runner

The runner module orchestrates the compilation and execution of the shell’s dynamically generated code.

It acts as the coordinator between the external system (using shellout to invoke the Gleam compiler) and the internal Erlang VM (using the runtime FFI to dynamically load and execute the resulting .beam bytecode).

Values

pub fn build_project() -> Result(String, #(Int, String))

Triggers a full compilation of the host project using the Gleam CLI. This is used when the user types the compile command in the REPL, allowing them to rebuild their background application without leaving the shell.

pub fn run(
  binding: option.Option(binding.Binding),
) -> result.Evaluation

The core execution pipeline for evaluated code.

  1. Uses shellout to run gleam build --target erlang. This compiles the temporary gsh_eval.gleam file into a .beam file without booting a new VM.
  2. If compilation succeeds, it uses the runtime FFI to hot-load gsh_eval.beam into the current VM and executes the gsh_entry function.
  3. Catches and formats any compiler or runtime errors into a safe Evaluation record.
Search Document