Sarek_ppx_intrinsictype parsed_type = | PTSimple of string| PTArray of parsed_type| PTVec of parsed_type| PTArrow of parsed_type * parsed_typeParsed type representation for intrinsic declarations
val parsed_type_of_core_type : Ppxlib.core_type -> parsed_typeExtract parsed type from a core_type
Extract type name from a core_type for registry registration (string representation)
Get the full module path from a location. For wrapped libraries like Sarek_stdlib, modules are accessed as Sarek_stdlib.Float32, so we need Sarek_stdlib; Float32 as the path. This is derived from the directory structure.
Convert simple type name to Sarek_types representation
val flatten_arrow : parsed_type -> parsed_type list * parsed_typeFlatten a parsed arrow type into (arg_types, return_type). E.g., PTArrow(a, PTArrow(b, c)) becomes (a; b, c)
val sarek_type_of_simple_parsed :
loc:Ppxlib.location ->
parsed_type ->
Ppxlib.expressionConvert a non-arrow parsed type to Sarek_types representation
val sarek_type_of_parsed :
loc:Ppxlib__.Location.t ->
parsed_type ->
Ppxlib.expressionConvert parsed type to Sarek_types representation. Flattens arrow types so a -> b -> c becomes TFun(a; b, c).
Convert type name string to Sarek_types representation (for backward compat)
Build a function type from argument types and return type
val expand_sarek_intrinsic_type :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.payload ->
Ppxlib_ast.Ast.structure_item listExtension for type%sarek_intrinsic - handles type registration
Extract argument types and return type from a function type
val expand_sarek_intrinsic_fun :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.payload ->
Ppxlib_ast.Ast.structure_item listExtension for let%sarek_intrinsic - handles function registration
val expand_sarek_intrinsic :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.payload ->
Ppxlib_ast.Ast.structure_item listCombined extension for %sarek_intrinsic - handles both types and functions
val expand_sarek_extend :
ctxt:Ppxlib.Expansion_context.Extension.t ->
Ppxlib.payload ->
Ppxlib_ast.Ast.structure_itemExtension for %sarek_extend - allows extending intrinsics for new backends.
Syntax: let%sarek_extend Module.func = fun dev -> if ... then "new_code" else Module.func_device dev
This updates the Module.func_device_ref to point to the new function, which chains to the original via Module.func_device.