Sarek_typesPrimitive types supported in GPU kernels (core language only). Numeric types like float32, float64, int64 are library-defined.
Registered type name - for library-defined types like float32, float64, int64. These are not built-in but are registered by libraries via @@sarek.type.
type typ = | TPrim of prim_typePrimitive types (core language)
*)| TReg of registered_typeRegistered types (library-defined: float32, float64, int64, etc.)
*)| TVar of tvar Stdlib.refUnification variable
*)| TVec of typVector type (GPU array parameter)
*)| TArr of typ * memspaceLocal array with memory space
*)| TFun of typ list * typFunction type
*)| TRecord of string * (string * typ) listRecord type: name, fields
*)| TVariant of string * (string * typ option) listVariant type: name, constructors
*)| TTuple of typ listTuple type
*)Types
and tvar = | Unbound of int * intid, level for generalization
*)| Link of typResolved to this type
*)val fresh_tvar : ?level:int -> unit -> typCreate a fresh unbound type variable at given level
val occurs : int -> typ -> boolCheck if a type variable occurs in a type (for occurs check)
val unify : typ -> typ -> (unit, unify_error) Stdlib.resultUnify two types
val pp_prim : Stdlib.Format.formatter -> prim_type -> unitPretty printing
val pp_registered : Stdlib.Format.formatter -> registered_type -> unitval pp_memspace : Stdlib.Format.formatter -> memspace -> unitval pp_typ : Stdlib.Format.formatter -> typ -> unitval typ_to_string : typ -> stringHelper functions to construct common types.
val t_unit : typPrimitive type constructors
val t_bool : typval t_int32 : typval t_float32 : typRegistered numeric types (library-defined).
These are not built-in primitives but use TReg for type-checking. They must be registered via @@sarek.type attributes.
val t_float64 : typval t_int64 : typval t_int : typval t_char : typBoolean-returning functions to check type properties.
For Result-returning validators with error messages, see Sarek_typer:
check_numeric: Validates numeric types with location-aware errorscheck_integer: Validates integer types with location-aware errorscheck_boolean: Validates boolean types with location-aware errorsval is_numeric : typ -> boolCheck if type is numeric (includes both core int32 and registered float/int types).
val is_integer : typ -> boolCheck if type is integer (core int32 or registered int64)
val is_float : typ -> boolCheck if type is floating point (registered types)
val is_boolean : typ -> boolCheck if type is boolean
val is_tvar : typ -> boolCheck if type is an unbound type variable
Functions to convert between different type representations.
val type_of_type_expr : Sarek_ast.type_expr -> typConvert AST type expression to type (with fresh type variables). Core types (unit, bool, int32) are handled directly. Other types (float32, float64, int64, etc.) are looked up in the type registry.
val memspace_of_ast : Sarek_ast.memspace -> memspaceConvert memspace from AST to types