Module Acutis.Typechecker

Type-checks the untyped Ast.t and constructs a typed tree.

module Type : sig ... end

Manages the type definitions.

type echo = [
  1. | `Var of string
  2. | `String of string
  3. | `Field of echo * string
]
type scalar = [
  1. | `Int of int
  2. | `Float of float
  3. | `String of string
]
type scalar_sum =
  1. | Scalar_sum_none
  2. | Scalar_sum_int of Set.Int.t Type.sum
  3. | Scalar_sum_string of Set.String.t Type.sum
type union_tag =
  1. | Union_tag_none
  2. | Union_tag_int of string * int * Type.sum_union_int
  3. | Union_tag_string of string * string * Type.sum_union_string
type construct = private
  1. | Construct_tag
type destruct = private
  1. | Destruct_tag
type _ pat =
  1. | Scalar : scalar * scalar_sum -> 'a pat
  2. | Nil : 'a pat
  3. | Cons : 'a pat -> 'a pat
    (*

    This always contains a Tuple.

    *)
  4. | Tuple : 'a pat list -> 'a pat
  5. | Record : union_tag * 'a pat Map.String.t * Type.record -> 'a pat
  6. | Dict : 'a pat Map.String.t * Set.String.t Stdlib.ref -> 'a pat
    (*

    The set is part of a Type.ty.Dict.

    *)
  7. | Var : string -> 'a pat
  8. | Block : nodes -> construct pat
  9. | Field : construct pat * string -> construct pat
  10. | Any : destruct pat

We use a GADT to prove that certain patterns may only appear when constructing and certain patterns may only appear when destructuring.

and node =
  1. | Text of string * Ast.trim * Ast.trim
  2. | Echo of (Ast.echo_format * echo) list * Ast.echo_format * echo * Ast.escape
  3. | Match of Loc.t * construct pat Nonempty.t * Type.t Nonempty.t * case Nonempty.t
  4. | Map_list of Loc.t * construct pat * Type.t Nonempty.t * case Nonempty.t
  5. | Map_dict of Loc.t * construct pat * Type.t Nonempty.t * case Nonempty.t
  6. | Component of string * construct pat Map.String.t
and case = {
  1. pats : (Loc.t * destruct pat Nonempty.t) Nonempty.t;
  2. bindings : string list;
    (*

    The binding list is needed to help produce runtime instructions.

    *)
  3. nodes : nodes;
}
and nodes = node list
type t = {
  1. nodes : nodes;
  2. types : Type.t Map.String.t;
}
type ('a, 'b) source =
  1. | Src of string * 'a
  2. | Fun of string * Type.t Map.String.t * 'b
val make_components : (Ast.t, 'a) source Map.String.t -> (t, 'a) source Map.String.t
val make : root:string -> (t, 'a) source Map.String.t -> Ast.t -> t
val make_interface_standalone : Ast.interface -> Type.t Map.String.t