typer.mli 2.74 KB
Newer Older
1 2
open Ident

3 4 5 6
type t
val serialize: t Serialize.Put.f
val deserialize: t Serialize.Get.f

7
exception NonExhaustive of Types.descr
8
exception Constraint of Types.descr * Types.descr
9
exception ShouldHave of Types.descr * string
10
exception WrongLabel of Types.descr * label
11
exception UnboundId of id * bool
12
exception UnboundExtId of Types.CompUnit.t * id
13
exception ShouldHave2 of Types.descr * string * Types.descr
14
exception Error of string
15 16
exception Warning of string * Types.t

17
val empty_env: t
18

19
val register_types : Types.CompUnit.t -> t -> unit
20
  (* Register types of the environment for the pretty-printer *)
21

22
val enter_cu : U.t -> Types.CompUnit.t -> t -> t 
23
val find_cu  : U.t -> t -> Types.CompUnit.t
24

25 26
val find_value: id -> t -> Types.t
val enter_type: id -> Types.t -> t -> t
27
val iter_values: t -> (id -> Types.t -> unit) -> unit
28

29 30
val typ: t -> Ast.ppat -> Types.Node.t
val pat: t -> Ast.ppat -> Patterns.node
31

32 33 34 35
val dump_types: Format.formatter -> t -> unit
val dump_ns: Format.formatter -> t -> unit
val set_ns_table_for_printer: t -> unit

36 37 38 39 40 41 42 43

val type_schema: t -> U.t -> string -> t

val type_ns : t -> U.t -> Ns.t -> t

val type_expr: t -> Ast.pexpr -> Typed.texpr * Types.descr

val type_defs: t -> (Location.loc * U.t * Ast.ppat) list -> t
44 45 46 47 48 49

val type_let_decl: t -> Ast.ppat -> Ast.pexpr -> 
  t * Typed.let_decl * (id * Types.t) list

val type_let_funs: t -> Ast.pexpr list -> 
  t * Typed.texpr list * (id * Types.t) list
50
  (* Assume that all the expressions are Abstractions *)
51

52

53
val get_schema_validator: string -> Ns.qname -> Value.t -> Value.t
54
val get_schema_names: t -> U.t list  (** registered schema names *)
55

56 57
(* Operators *)

58
type type_fun = Types.t -> bool -> Types.t
59

60
val register_op: string -> int -> (type_fun list -> type_fun) -> unit
61
val flatten: type_fun -> type_fun
62 63 64 65 66 67 68 69 70 71 72 73 74



module IType : sig
  type node

  val get_type: node -> Types.t

  val itype: Types.t -> node
  val delayed: unit -> node
  val link: node -> node -> unit

  val ior: node -> node -> node
75
  val iand: node -> node -> node
76 77 78 79 80 81

  val times: node -> node -> node
  val record: bool -> (node * node option) Ident.label_map -> node
  val xml: node -> node -> node
  val optional: node -> node

82
  val get_ct: node -> Types.t * node
83 84 85 86 87 88 89 90 91 92 93 94 95 96

(* Regular expression *)
  type regexp
  val rexp: regexp -> node
  val simplify_regexp: regexp -> regexp
  val eps: regexp
  val emp: regexp
  val seq: regexp -> regexp -> regexp
  val alt: regexp -> regexp -> regexp
  val star: regexp -> regexp
  val mix: regexp -> regexp
  val elem: node -> regexp
end

97
(* Forward definitions *)
98 99 100 101 102 103
val from_comp_unit: (Types.CompUnit.t -> t) ref
val has_comp_unit: (U.t -> bool) ref
val has_ocaml_unit: (U.t -> bool) ref
val has_static_external: (string -> bool) ref
val load_schema: 
  (U.t -> string -> (Types.t * (Value.t -> Value.t)) Ident.Env.t) ref