Sarek_ppxval registered_types : Sarek_ppx_lib.Sarek_ast.type_decl list Stdlib.refval registered_mods : Sarek_ppx_lib.Sarek_ast.module_item list Stdlib.refval tdecl_key : Sarek_ppx_lib.Sarek_ast.type_decl -> stringval dedup_tdecls :
Sarek_ppx_lib.Sarek_ast.type_decl list ->
Sarek_ppx_lib.Sarek_ast.type_decl listval dedup_mods :
Sarek_ppx_lib.Sarek_ast.module_item list ->
Sarek_ppx_lib.Sarek_ast.module_item listval core_type_to_sarek_type_expr :
loc:Ppxlib.Location.t ->
Ppxlib.core_type ->
Sarek_ppx_lib.Sarek_ast.type_exprval register_sarek_module_item :
loc:'a ->
Sarek_ppx_lib.Sarek_ast.module_item ->
unitScan a single .ml file for @@sarek.type and @sarek.module declarations
Scan a directory for .ml files with Sarek declarations, or scan a single file
val generate_field_accessors :
loc:Ppxlib.location ->
Ppxlib.type_declaration ->
Ppxlib.structure_item listGenerate field accessor functions for a record type. Example: for type point with fields x and y, generates: let sarek_get_point_x (p : point) : float32 = p.x let sarek_get_point_y (p : point) : float32 = p.y
Extract type name from a core_type for registry registration
Calculate the size in bytes of a sarek type based on its fields. Uses 4 bytes for int32/float32, 8 bytes for int64/float64.
Get the accessor function for a field type (legacy SPOC path removed)
Get the setter function for a field type (legacy SPOC path removed)
Get the field count (number of primitive fields, counting nested as 1 for now)
val gen_field_read :
loc:Ppxlib.location ->
Ppxlib.core_type ->
Ppxlib.expression ->
Ppxlib.expressionHelper to generate a V2 field read expression based on field type. Dispatches to the correct Custom_helpers function. For nested custom types, generates a call using the nested type's _custom accessor.
val gen_field_write :
loc:Ppxlib.location ->
Ppxlib.core_type ->
Ppxlib.expression ->
Ppxlib.expression ->
Ppxlib.expressionHelper to generate a V2 field write expression based on field type.
val generate_custom_value :
loc:Ppxlib__.Location.t ->
Ppxlib.type_declaration ->
Ppxlib.structure_item listGenerate a <name>_custom value for Spoc_core.Vector.custom_type. For a record type (e.g., point with float32 fields), generates get/set functions using Ctypes pointer arithmetic. Supports nested custom types via their _custom accessor.
val generate_interp_helpers :
loc:Ppxlib.location ->
Ppxlib.type_declaration ->
Ppxlib.structure_item listGenerate interpreter helper module for type-safe value conversion. Provides typed constructors for custom type handling.
val generate_type_registration :
loc:Ppxlib.location ->
Ppxlib.type_declaration ->
Ppxlib.structure_item listGenerate runtime registration code for a type. The PPX emits calls to Sarek_registry at module initialization time so type info is available to codegen (record fields, variants, sizes).
val expand_kernel :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.expression ->
Ppxlib.expressionThe main kernel expansion function
Register sarek.module bindings on any structure we process, so libraries can publish module items for use in kernels.
This generates registration code that runs at module initialization time, registering the items in Sarek_ppx_registry. This allows cross-module references: a library can define @sarek.module items and link with the PPX so they become available to kernels in other compilation units.
val expand_sarek_include :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.payload ->
Ppxlib_ast.Ast.structure_item%sarek_include "path/to/file.ml" - Include types and module items from another file.
This scans the specified file for @@sarek.type and @sarek.module declarations and registers them for use in kernels in the current file. The path is relative to the current file's directory.
Usage: %sarek_include "registered_defs.ml"
let kernel = %kernel fun ... -> let open Registered_defs in ... use types and functions from registered_defs.ml ...