Sarek_transpilePure OCaml-kernel-source to GPU-source transpiler.
Sarek_transpile converts an OCaml kernel source string through the full Sarek frontend (parse → type → convergence → mono → tailrec → lower) and emits GPU source code for the requested backend.
The library is FFI-free: it does not depend on spoc_core or ctypes and therefore links cleanly as bytecode and (with polyfills) under js_of_ocaml.
type error = | Parse_error of string * Sarek_ast.locOCaml parser or Sarek parse error with message and location.
*)| Type_error of Sarek_error.error listType-inference or constraint-solving failure.
*)| Convergence_error of Sarek_error.error listBarrier-safety analysis failure.
*)| Unsupported_native of Sarek_ast.locKernel contains [%native] which cannot be transpiled purely.
| Internal_error of stringUnexpected exception — indicates a bug, not a user error.
*)Structured error type. Every frontend failure is converted to one of these variants; no exception escapes of_source.
val string_of_error : error -> stringstring_of_error e returns a human-readable representation of e. Intended for debugging and test output.
of_source backend src parses src as an OCaml kernel expression and runs the full frontend pipeline:
Sarek_ast.kernel[%native] rejectionSarek_typer.infer_kernel)Sarek_convergence.check_kernel)sarek_codegenReturns Ok gpu_source on success, or Error e with a structured description of the first failure encountered.
All frontend exceptions are caught and converted to error values.
of_source_with_abi backend src runs the same frontend pipeline as of_source and additionally returns the ABI descriptor as a JSON string.
WGSL backend: returns Ok (wgsl_code, abi_json) on success.Error (Internal_error "ABI is only defined for the WGSL backend") without running the pipeline.All frontend exceptions are caught and converted to error values.