Module Mlsem_lang.MAst

module SA = Mlsem_system.Ast
type e =
  1. | Hole of int
  2. | Exc
    (*

    Expression of type empty

    *)
  3. | Void
    (*

    Expression of type void

    *)
  4. | Voidify of t
    (*

    Evaluate the expression inside, but give it the void type, even if it diverges

    *)
  5. | Ignore of t
    (*

    Evaluate the expression inside, but give it the void type, or empty if it diverges

    *)
  6. | Value of Mlsem_types.GTy.t
  7. | Var of Mlsem_common.Variable.t
  8. | Constructor of SA.constructor * t list
  9. | GConstructor of SA.gconstructor * t list
  10. | Lambda of Mlsem_types.Ty.t list * SA.param_annot * Mlsem_common.Variable.t * t
    (*

    The first parameter is a suggested type decomposition, similarly to let-bindings

    *)
  11. | LambdaRec of (SA.param_annot * Mlsem_common.Variable.t * t) list
  12. | Ite of t * Mlsem_types.Ty.t * t * t
  13. | App of t * t
  14. | Operation of SA.operation * t
  15. | Projection of SA.projection * t
  16. | Declare of Mlsem_types.Ty.t list * Mlsem_common.Variable.t * t
    (*

    Declaration of an uninitialized mutable variable. The variable provided must be mutable (cf. MVariable.create). The type system will not check that the variable is assigned before use. The first parameter is a suggested type decomposition, similarly to let-bindings: it applies to the values later assigned to the variable.

    *)
  17. | Let of Mlsem_types.Ty.t list * Mlsem_common.Variable.t * t * t
    (*

    The first parameter is a suggested type decomposition. The variable must be immutable: mutable variables are bound by Declare.

    *)
  18. | TypeCast of t * Mlsem_types.GTy.t * SA.check
  19. | TypeCoerce of t * Mlsem_types.GTy.t * SA.check
  20. | VarAssign of Mlsem_common.Variable.t * t
    (*

    The variable provided must be mutable (cf. MVariable.create)

    *)
  21. | Loop of t
    (*

    A void expression that may be evaluated multiple times.

    *)
  22. | Seq of t * t
    (*

    Evaluate the first expression, then the second.

    *)
  23. | Try of t list
    (*

    May jump from a branch to another. Used to model try-with expressions.

    *)
  24. | Alt of SA.alt_settings * t list
    (*

    Evaluate branches independently. The result is (the intersection of) the result of the branches that do not fail.

    *)
val map : (t -> t) -> t -> t
val map' : (t -> t option) -> t -> t
val iter : (t -> unit) -> t -> unit
val iter' : (t -> bool) -> t -> unit
val fill_hole : int -> t -> t -> t
val fv : t -> Mlsem_common.VarSet.t
val vars : t -> Mlsem_common.VarSet.t
val refresh : t -> t
val to_system_ast : t -> SA.t

Encodes the remaining mutable variables as operations on an abstract reference type, yielding a term of the functional core language.

  • raises Invalid_argument

    if a binder other than a Declare binds a mutable variable, if a Declare or a VarAssign targets an immutable one, or if the term still contains a hole.

val pp_e : Stdlib.Format.formatter -> e -> unit
val pp : Stdlib.Format.formatter -> t -> unit