gsh/evaluator/result

The result module defines the core data structures returned by the evaluation engine back to the REPL’s main state loop.

When the shell processes user input, it needs more than just a raw string to print. It requires structured metadata detailing execution success, error classifications, and any new lexical artifacts (variables, imports, types, functions) that must be merged into the persistent ShellState.

Types

Classifies the exact failure mode of an evaluation attempt.

pub type ErrorKind {
  NoError
  CompileError
  RuntimeError
}

Constructors

  • NoError

    The execution completed successfully without any compilation or VM faults.

  • CompileError

    The code failed the Gleam compiler’s strict static analysis (e.g., syntax error, type mismatch, or unknown identifier).

  • RuntimeError

    The code compiled successfully but triggered a fatal exception within the Erlang VM during runtime (e.g., division by zero, let assert failure).

Encapsulates the complete lifecycle outcome of a single REPL evaluation prompt.

pub type Evaluation {
  Evaluation(
    output: String,
    success: Bool,
    error_kind: ErrorKind,
    new_binding: option.Option(binding.Binding),
    new_import: option.Option(String),
    new_type: option.Option(#(String, String)),
    new_function: option.Option(#(String, String)),
  )
}

Constructors

  • Evaluation(
      output: String,
      success: Bool,
      error_kind: ErrorKind,
      new_binding: option.Option(binding.Binding),
      new_import: option.Option(String),
      new_type: option.Option(#(String, String)),
      new_function: option.Option(#(String, String)),
    )

    Arguments

    output

    The final formatted string (including ANSI syntax highlighting and debug latency logs) ready to be printed to the terminal.

    success

    True if the generated code successfully compiled and executed without a VM crash; False otherwise.

    error_kind

    The specific classification of error if the evaluation failed.

    new_binding

    A successfully evaluated variable assignment (e.g., let x = 1) to be appended to the active lexical scope.

    new_import

    A successfully evaluated module import (e.g., import gleam/list) to be tracked for subsequent file generations.

    new_type

    A custom type declaration (stored as #(Name, Source)) to be injected into future evaluations.

    new_function

    A custom function definition (stored as #(Name, Source)) to be injected into future evaluations.

Search Document