jon.recoil.org

Module Typedecl_properties

An abstract interface for properties of type definitions, such as variance and immediacy, that are computed by a fixpoint on mutually-recursive type declarations. This interface contains all the operations needed to initialize and run the fixpoint computation, and then (optionally) check that the result is consistent with the declaration or user expectations.

type ('prop, 'req) property = {
  1. eq : 'prop -> 'prop -> bool;
  2. merge : prop:'prop -> new_prop:'prop -> 'prop;
  3. default : Typedecl_properties.decl -> 'prop;
  4. compute : Env.t -> Typedecl_properties.decl -> 'req -> 'prop;
  5. update_decl : Typedecl_properties.decl -> 'prop -> Typedecl_properties.decl;
  6. check : Env.t -> Ident.t -> Typedecl_properties.decl -> ('req * 'req option) -> unit;
}

'prop represents the type of property values (Types.Variance.t, just 'bool' for immediacy, etc).

'req represents the property value required by the author of the declaration, if they gave an expectation: type +'a t = ....

Some properties have no natural notion of user requirement, or their requirement is global, or already stored in type_declaration; they can just use unit as 'req parameter.

val compute_property : ('prop, 'req) Typedecl_properties.property -> Env.t -> (Ident.t * Typedecl_properties.decl) list -> ('req * 'req option) list -> (Ident.t * Typedecl_properties.decl) list

compute_property prop env decls req performs a fixpoint computation to determine the final values of a property on a set of mutually-recursive type declarations. The req argument must be a list of the same size as decls, providing the user requirement for each declaration.

For each corresponding 'req * 'req option and declaration, if the declaration has an unboxed version, the 'req option is Some and contains the user requirement for the unboxed version.

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