typer.mli 1.95 KB
Newer Older
1 2
open Ident

3 4
type t

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

15
val empty_env: t
16

17
val register_types : string -> t -> unit
18
  (* Register types of the environment for the pretty-printer *)
19

20 21
val enter_cu : U.t -> Compunit.t -> t -> t 
val find_cu  : U.t -> t -> Compunit.t
22

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

27 28
val typ: t -> Ast.ppat -> Types.Node.t
val pat: t -> Ast.ppat -> Patterns.node
29

30 31 32 33
val dump_types: Format.formatter -> t -> unit
val dump_ns: Format.formatter -> t -> unit
val set_ns_table_for_printer: t -> unit

34 35 36

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

37
val type_ns : t -> U.t -> Ns.Uri.t -> t
38

39 40
val type_keep_ns : t -> bool -> t

41 42 43
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_names: t -> U.t list  (** registered schema names *)
54

55 56
(* Operators *)

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

59
val register_op: string -> int -> (type_fun list -> type_fun) -> unit
60
val flatten: type_fun -> type_fun
61

62
(* Forward definitions *)
63 64 65 66 67
val from_comp_unit: (Compunit.t -> t) ref
  (* From Librarian *)
val load_comp_unit: (U.t -> Compunit.t) ref
  (* From Librarian *)

68 69
val has_ocaml_unit: (U.t -> bool) ref
val has_static_external: (string -> bool) ref
70 71


72
val load_schema: 
73
  (U.t -> string -> (Types.t * Schema_validator.t) Ident.Env.t) ref