gsh/evaluator/runner

The runner module orchestrates the compilation and execution pipeline for the shell’s dynamically generated REPL modules.

It acts as the bridge between the host filesystem and the Erlang VM, utilizing shellout to invoke the Gleam compiler for static analysis and Erlang generation, and utilizing the runtime FFI to dynamically compile, load, and execute the resulting code directly in memory.

Values

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

Triggers a full compilation of the host workspace using the Gleam CLI.

This is invoked by the compile command in the REPL, allowing developers to rebuild their background application and trigger Erlang VM hot-reloads without dropping their active shell session.

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

The core execution pipeline for evaluated code.

Execution Lifecycle:

  1. Isolated Compilation: Invokes gleam compile-package targeting an isolated build/dev/erlang/gsh_eval output directory. This ensures the REPL’s temporary files never corrupt or overwrite the host project’s build cache.
  2. In-Memory Loading: Reads the resulting .erl file and uses Erlang’s native compiler FFI to compile it directly into RAM, bypassing .beam disk I/O.
  3. Execution: Invokes the dynamically loaded gsh_entry function, capturing the evaluation success or gracefully intercepting Erlang VM runtime crashes.
Search Document