Module Ast

Located, named surface syntax, including forms removed by desugaring.

type loc = {
  1. start_p : Stdlib.Lexing.position;
  2. end_p : Stdlib.Lexing.position;
}
type 'a node = {
  1. it : 'a;
  2. loc : loc;
}
val mk : loc -> 'a -> 'a node
val dummy_loc : loc

Location for synthesized nodes; its positions are outside any source file.

type binder = {
  1. bd_name : string;
  2. bd_loc : loc;
}
type typ = typ_desc node
and typ_desc =
  1. | TInt
  2. | TBool
  3. | TString
  4. | TTop
  5. | TVar of string
  6. | TArr of typ * typ
  7. | TAnd of typ * typ
  8. | TOr of typ * typ
  9. | TRcd of (string * typ) list
  10. | TMu of binder * typ
  11. | TSig of typ
  12. | TMarr of typ * typ
type param = {
  1. p_bind : binder;
  2. p_typ : typ;
}
type lit =
  1. | LInt of int
  2. | LBool of bool
  3. | LString of string
type binop =
  1. | Add
  2. | Sub
  3. | Mul
  4. | Div
  5. | Mod
  6. | Lt
  7. | Le
  8. | Gt
  9. | Ge
  10. | Eq
  11. | Ne
  12. | Cat
  13. | And
  14. | Or
type unop =
  1. | Neg
  2. | Not
type merge_kind =
  1. | MNon
    (*

    Independent operands, written ;.

    *)
  2. | MDep
    (*

    The right operand can use the left operand's fields, written ;;.

    *)
type sandbox =
  1. | Sandboxed
  2. | Open
type exp = exp_desc node
and exp_desc =
  1. | EVar of string
  2. | ELit of lit
  3. | EUnit
  4. | EAnnot of exp * typ
  5. | EBinop of binop * exp * exp
  6. | EUnop of unop * exp
  7. | EIf of exp * exp * exp
  8. | ELam of param list * exp
  9. | EApp of exp * exp
  10. | ERcd of (string * exp) list
  11. | EField of exp * string
  12. | EMerge of merge_kind * exp * exp
  13. | ELet of binding * exp
  14. | EOpen of exp * exp
  15. | EInl of exp
  16. | EInr of exp
  17. | ECase of exp * binder * exp * binder * exp
  18. | EFold of exp
  19. | EUnfold of exp
  20. | EStruct of sandbox * decl list
  21. | EFunctor of sandbox * param list * exp
  22. | EMatch of exp * (binder * binder list * exp) list
    (*

    Arms contain a constructor name, payload binders and a body. A constructor named _ denotes the wildcard arm.

    *)
  23. | EQuery
  24. | EIndex of exp * int
  25. | EBox of exp * exp
and binding = {
  1. b_rec : bool;
  2. b_bind : binder;
  3. b_params : param list;
  4. b_ann : typ option;
  5. b_exp : exp;
}
and decl = decl_desc node
and decl_desc =
  1. | DLet of binding
  2. | DModule of binder * exp
  3. | DOpen of exp
  4. | DType of binder * typ
  5. | DAdt of binder * (binder * typ list) list
    (*

    A nonempty constructor list, in declaration order.

    *)
type import_source =
  1. | IAuto
  2. | IFile of string
  3. | IInline of typ
type program = {
  1. imports : (binder * import_source) list;
  2. decls : decl list;
  3. main : exp option;
    (*

    An optional synthesized result expression. The parser leaves this unset; a source entry point is a declaration named main.

    *)
}
type intf = {
  1. i_aliases : (binder * typ) list;
  2. i_typ : typ;
}

A .scei file: ordered type aliases followed by its interface type.

val name_of_decl : decl -> string option

The name bound by a value or module declaration; other declarations have no exported value name.

val decl_labels : decl list -> (string * loc) list

Value and module names with declaration locations, in source order. Duplicates are retained.

val string_of_binop : binop -> string
val string_of_unop : unop -> string