Mlsem_system.CheckerType checker for the functional core language.
The checker is purely a verifier: it takes an expression together with a complete Annot.t — the derivation reconstructed by Mlsem_system.Reconstruction — and computes the type it proves, raising Error.Untypeable if the annotation is not a valid derivation. It never searches for an annotation itself.
val is_type_test_unsat :
tau:Mlsem_types.Ty.t ->
Mlsem_types.GTy.t ->
Mlsem_types.Ty.tis_type_test_unsat ~tau ty returns a type that is empty if and only if a branch tau of a typecase on an expression of type ty is unreachable
val typeof : Mlsem_common.Env.t -> Annot.Annot.t -> Ast.t -> Mlsem_types.GTy.ttypeof env a e returns the type that a proves for e under env.
The annotation must structurally match the expression, i.e. have the same shape at every node. The result is memoised in the annotation, and the cache is not keyed by env: a given annotation node must therefore only ever be typed under one environment. The reconstruction maintains this by only ever applying to an annotation substitutions that are disjoint from the environment's variables.
val generalizable_vars :
e:Ast.t ->
Mlsem_common.Env.t ->
Mlsem_types.GTy.t ->
Mlsem_types.MVarSet.tgeneralizable_vars ~e env ty returns the variables of ty that can be generalized for the definition e: those that do not occur in env, or none if e is not generalizable under the value restriction (see Config.value_restriction).
val scheme_of_def :
Mlsem_types.MVarSet.t ->
Mlsem_types.GTy.t ->
Mlsem_types.TyScheme.tscheme_of_def gen ty quantifies the variables of gen in ty, then simplifies the result with TyScheme.bot_instance. Together with the cached type of a Let definition and its set of generalized variables, this gives the scheme of the definition without needing an environment.
val generalize :
e:Ast.t ->
Mlsem_common.Env.t ->
Mlsem_types.GTy.t ->
Mlsem_types.TyScheme.tgeneralize ~e env ty quantifies the variables of ty that do not occur in env, then simplifies the result with TyScheme.bot_instance. Under the value restriction (see Config.value_restriction), applications are not generalized as their evaluation may be effectful. Equivalent to scheme_of_def (generalizable_vars ~e env ty) ty.
val typeof_def :
Mlsem_common.Env.t ->
Annot.Annot.t ->
Ast.t ->
Mlsem_types.TyScheme.ttypeof followed by generalize. Used for top-level definitions; Let definitions are instead generalized according to the set of variables stored in their annotation.