Module Acutis_internals.Typechecker

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

type 'a map_string := 'a Stdlib.Map.Make(Stdlib.String).t
type 'a map_int := 'a Stdlib.Map.Make(Stdlib.Int).t
type set_int := Stdlib.Set.Make(Stdlib.Int).t
type set_string := Stdlib.Set.Make(Stdlib.String).t
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 Type.sum
  3. | Scalar_sum_string of set_string 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 _ 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 * Type.record -> 'a pat
  6. | Dict : 'a pat map_string * set_string 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
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.scheme;
}
type ('a, 'b) source =
  1. | Src of string * 'a
  2. | Fun of string * Type.scheme * 'b
val make_components : (Ast.t, 'a) source map_string -> (t, 'a) source map_string
val make : root:string -> (t, 'a) source map_string -> Ast.t -> t
val make_interface_standalone : Ast.interface -> Type.scheme