Module Quill.Kernel

Code execution kernels.

A kernel executes code and produces outputs. The interface is abstract to support different backends: in-process toplevels, subprocess-based kernels, remote kernels, etc.

Kernel status

type status =
  1. | Starting
  2. | Idle
  3. | Busy
  4. | Shutting_down
    (*

    The type for kernel lifecycle status.

    *)

Kernel events

type event =
  1. | Output of {
    1. cell_id : Cell.id;
    2. output : Cell.output;
    }
  2. | Finished of {
    1. cell_id : Cell.id;
    2. success : bool;
    }
  3. | Status_changed of status
    (*

    The type for kernel events.

    • Output is emitted for each piece of output during execution.
    • Finished signals that execution of a cell has completed.
    • Status_changed signals a kernel lifecycle change.
    *)

Kernel interface

type t = {
  1. execute : cell_id:Cell.id -> code:string -> unit;
  2. interrupt : unit -> unit;
  3. complete : code:string -> pos:int -> string list;
  4. status : unit -> status;
  5. shutdown : unit -> unit;
}

The type for kernel handles.

  • execute ~cell_id ~code submits code for execution. Results are delivered as event values through the callback registered at kernel creation time.
  • interrupt () requests interruption of the current execution.
  • complete ~code ~pos returns completion candidates at the given cursor position in code.
  • status () returns the current kernel status.
  • shutdown () initiates graceful shutdown.