typer.mli 2.19 KB
Newer Older
1
open Ident
2
open Location
3

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

exception Warning of string * Types.t

15 16
val warning: loc -> string -> unit
val error: loc -> string -> 'a
17

18
include Custom.T
19

20
val from_comp_unit: (Types.CompUnit.t -> t) ref
21 22
val has_comp_unit: (U.t -> bool) ref
val has_ocaml_unit: (U.t -> bool) ref
23

24 25
val has_static_external: (string -> bool) ref

26 27
val empty_env: t
val get_ns_table : t -> Ns.table
28

29 30
val register_types : Types.CompUnit.t -> t -> unit

31
val enter_ns : U.t -> Ns.t -> t -> t
32
val enter_schema: U.t -> string -> t -> t
33
val find_schema: U.t -> t -> string
34
val enter_cu : U.t -> Types.CompUnit.t -> t -> t 
35
val find_cu  : U.t -> t -> Types.CompUnit.t
36

37 38 39
val enter_value: id -> Types.t -> t -> t
val enter_values: (id * Types.t) list -> t -> t
val find_value: id -> t -> Types.t
40
val iter_values: t -> (id -> Types.t -> unit) -> unit
41

42 43 44
val enter_type: id -> Types.t -> t -> t
val enter_types: (id * Types.t) list -> t -> t
val find_type: id -> t -> Types.t
45

46
val type_defs: t -> (Location.loc * U.t * Ast.ppat) list -> (id * Types.t) list
47 48
val typ: t -> Ast.ppat -> Types.Node.t
val pat: t -> Ast.ppat -> Patterns.node
49

50 51 52 53
val dump_types: Format.formatter -> t -> unit
val dump_ns: Format.formatter -> t -> unit
val set_ns_table_for_printer: t -> unit

54 55 56 57 58 59 60 61
val type_expr: 
  t -> Ast.pexpr -> Typed.texpr * Types.descr

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

64 65


66

67
val flatten: (Types.t -> bool -> Types.t) -> (Types.t -> bool -> Types.t)
68

69
(** {2 Schema stuff} *)
70

71
val get_schema_validator: string -> Ns.qname -> Value.t -> Value.t
72
val get_schema_names: t -> U.t list  (** registered schema names *)
73

74 75
(* Operators *)

76
type type_fun = Types.t -> bool -> Types.t
77

78
val register_op: string -> int -> (type_fun list -> type_fun) -> unit