← Back
REPL
Evaluator.eval [advanced]Interactive Elixir REPL with sandboxed evaluation
Interactive Elixir REPL with sandboxed evaluation
For the full interactive experience:
$ mix raxol.playground
Code
defp do_eval(model, code) do
case Evaluator.eval(model.evaluator, code,
timeout: @eval_timeout,
max_heap_bytes: @eval_max_heap_bytes,
max_result_bytes: @eval_max_output_bytes
) do
{:ok, result, new_eval} ->
output_lines = format_result(result)
new_history = [code | model.input_history] |> Enum.take(@max_history)
model
|> Map.put(:evaluator, new_eval)
|> Map.put(:input, "")
|> Map.put(:cursor, 0)
|> Map.put(:history_index, nil)
|> Map.put(:input_history, new_history)
|> add_output_lines([{"> #{code}", :input} | output_lines])
{:error, reason, _eval} ->
append_output(model, code, reason, :error)
end
end