typer.mli 1.86 KB
Newer Older
1 2
open Ident

3
exception NonExhaustive of Types.descr
4
exception Constraint of Types.descr * Types.descr
5
exception ShouldHave of Types.descr * string
6
exception WrongLabel of Types.descr * label
7
exception UnboundId of id * bool
8
exception UnboundExtId of Types.CompUnit.t * id
9
exception ShouldHave2 of Types.descr * string * Types.descr
10
exception Error of string
11 12 13

exception Warning of string * Types.t

14
include Custom.T
15

16
val from_comp_unit: (Types.CompUnit.t -> t) ref
17 18
val has_comp_unit: (U.t -> bool) ref
val has_ocaml_unit: (U.t -> bool) ref
19 20
val has_static_external: (string -> bool) ref

21
val empty_env: t
22

23
val register_types : Types.CompUnit.t -> t -> unit
24
  (* Register types of the environment for the pretty-printer *)
25

26
val enter_cu : U.t -> Types.CompUnit.t -> t -> t 
27
val find_cu  : U.t -> t -> Types.CompUnit.t
28

29 30
val find_value: id -> t -> Types.t
val enter_type: id -> Types.t -> t -> t
31
val iter_values: t -> (id -> Types.t -> unit) -> unit
32

33 34
val typ: t -> Ast.ppat -> Types.Node.t
val pat: t -> Ast.ppat -> Patterns.node
35

36 37 38 39
val dump_types: Format.formatter -> t -> unit
val dump_ns: Format.formatter -> t -> unit
val set_ns_table_for_printer: t -> unit

40 41 42 43 44 45 46 47

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
48 49 50 51 52 53

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
54
  (* Assume that all the expressions are Abstractions *)
55

56

57
val get_schema_validator: string -> Ns.qname -> Value.t -> Value.t
58
val get_schema_names: t -> U.t list  (** registered schema names *)
59

60 61
(* Operators *)

62
type type_fun = Types.t -> bool -> Types.t
63

64
val register_op: string -> int -> (type_fun list -> type_fun) -> unit
65
val flatten: type_fun -> type_fun