Quill_topSourceOCaml toplevel kernel for Quill.
Provides an in-process OCaml toplevel as a Quill.Kernel.t. Stdout and stderr are streamed in real time during execution. Rich outputs (images, HTML) are emitted via Quill.Cell.Display_tag semantic tags on the toplevel formatter.
initialize_if_needed () ensures the OCaml toplevel environment is initialized. Safe to call multiple times; only the first call has effect.
add_packages pkgs resolves each findlib package name and adds its directory to the toplevel load path, marking each as already linked into the executable. Unknown packages are silently skipped.
load_package pkg resolves the findlib package pkg and all its transitive dependencies, adds their directories, and dynamically loads their bytecode archives. Packages already loaded or marked in-core via add_packages are skipped. Raises if the package is not found.
install_printer name installs a toplevel pretty-printer by evaluating #install_printer name;;. The printer must be resolvable in the current toplevel environment (i.e. its module directory was previously added via add_packages). Silently does nothing on failure.
install_printer_fn ~ty f registers f as a pretty-printer for values of type ty (e.g. "Hugin.figure"). The type is looked up in the toplevel environment. Unlike install_printer, the function does not need to be resolvable by name -- it is passed directly. Silently does nothing if the type cannot be resolved.
val create :
?setup:(unit -> unit) ->
on_event:(Quill.Kernel.event -> unit) ->
unit ->
Quill.Kernel.tcreate ?setup ~on_event () creates a new OCaml toplevel kernel. Kernel events are delivered by calling on_event. setup is called once before the first cell execution, after toplevel initialization -- use it to call add_packages and install_printer.