Official release 4.12.1
type error =
| Non_separable_evar of string option
exception Error of Location.t * error

Exception raised when a type declaration is not separable, or when its separability cannot be established.

type mode = Types.Separability.t =
| Ind
| Sep
| Deepsep(*

The mode Sep ("separable") characterizes types that are indeed separable: either they only contain floating-point values, or none of the values at this type are floating-point values. On a type parameter, it indicates that this parameter must be separable for the whole type definition to be separable. For example, the mode signature for the type declaration type 'a t = 'a is ('a : Sep) t. For the right-hand side to be separable, the parameter 'a must be separable.

The mode Ind ("indifferent") characterizes any type -- separable or not. On a type parameter, it indicates that this parameter needs not be separable for the whole type definition to be separable. For example, type 'a t = 'a * bool does not require its parameter 'a to be separable as 'a * bool can never contain float values. Its mode signature is thus ('a : Ind) t.

Finally, the mode Deepsep ("deeply separable") characterizes types that are separable, and whose type sub-expressions are also separable. This advanced feature is only used in the presence of constraints. For example, type 'a t = 'b constraint 'a = 'b * bool may not be separable even if 'a is (its separately depends on 'b, a fragment of 'a), so its mode signature is ('a : Deepsep) t.

The different modes are ordered as Ind < Sep < Deepsep (from the least demanding to the most demanding).

val compute_decl : Env.t -> Types.type_declaration -> mode list

compute_decl env def returns the signature required for the type definition def in the typing environment env -- including signatures for the current recursive block.

The Error exception is raised if no such signature exists -- the definition will always be invalid. This only happens when the definition is marked to be unboxed.

Variant (or record) declarations that are not marked with the "@@unboxed" annotation, including those that contain several variants (or labels), are always separable. In particular, their mode signatures do not require anything of their type parameters, which are marked Ind.

Finally, if Config.flat_float_array is not set, then separability is not required anymore; we just use Ind as the mode of each parameter without any check.

Property interface (see Typedecl_properties). These functions rely on compute_decl and raise the Error exception on error.

val property : ( prop, unit ) Typedecl_properties.property
val update_decls : Env.t -> (Ident.t * Typedecl_properties.decl) list -> (Ident.t * Typedecl_properties.decl) list