gsh/evaluator/result
The result module defines the data structures returned by the evaluator.
When the REPL processes user input, it needs to know more than just what text to print to the screen. It needs to know if the execution succeeded, what type of error occurred if it failed, and whether there are any new variables, imports, or types that need to be saved into the shell’s persistent state.
Types
Classifies the outcome of the evaluation for error handling.
pub type ErrorKind {
NoError
CompileError
RuntimeError
}
Constructors
-
NoErrorThe evaluation completed successfully.
-
CompileErrorThe code failed to compile (e.g., syntax error, type mismatch).
-
RuntimeErrorThe code compiled successfully but crashed the Erlang VM during execution (e.g., division by zero, pattern match failure).
Represents the complete outcome of a single REPL evaluation cycle.
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),
new_function: option.Option(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), new_function: option.Option(String), )Arguments
- output
-
The final formatted string (including ANSI colors) to print to the terminal.
- success
-
True if the code compiled and ran without crashing; False otherwise.
- error_kind
-
The specific category of error if the evaluation failed.
- new_binding
-
A new variable assignment to save to state (e.g.,
let x = 1). - new_import
-
A new module import to save to state (e.g.,
import gleam/list). - new_type
-
A new custom type definition to save to state (e.g.,
pub type User { User }). - new_function
-
A new custom function definition to save to state.