typer.mli 2.39 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 ShouldHave2 of Types.descr * string * Types.descr
10
exception Error of string
11
12
val warning: loc -> string -> unit
val error: loc -> string -> 'a
13

14
include Custom.T
15

16
17
val empty_env: t
val get_ns_table : t -> Ns.table
18

19
val enter_ns : U.t -> Ns.t -> t -> t
20

21
22
23
val enter_value: id -> Types.t -> t -> t
val enter_values: (id * Types.t) list -> t -> t
val find_value: id -> t -> Types.t
24

25
26
27
val enter_type: id -> Types.t -> t -> t
val enter_types: (id * Types.t) list -> t -> t
val find_type: id -> t -> Types.t
28

29
30
31
val type_defs: t -> (id * Ast.ppat) list -> (id * Types.t) list
val typ: t -> Ast.ppat -> Types.Node.t
val pat: t -> Ast.ppat -> Patterns.node
32

33
34
35
36
37
38
39
40
41
val dump_types: Format.formatter -> t -> unit



val dump_ns: Format.formatter -> t -> unit
val set_ns_table_for_printer: t -> unit

val expr: t -> Ast.pexpr -> fv * Typed.texpr
val let_decl : t -> Ast.ppat -> Ast.pexpr -> Typed.let_decl
42

43
val type_check: 
44
  t -> Typed.texpr -> Types.descr -> bool -> Types.descr
45
  (* [type_check env e t precise] checks that expression [e] 
46
47
48
     has type [t] under typing environment [env]; if [precise=true], 
     also returns a possible more precise type for [e].
  *)
49
val type_let_decl: t -> Typed.let_decl -> (id * Types.t) list
50
     
51
val type_rec_funs: t -> Typed.texpr list -> (id * Types.t) list
52
  (* Assume that all the expressions are Abstractions *)
53
54
55

val report_unused_branches : unit -> unit
  (* Issue warnings for unused branches *)
56
val clear_unused_branches : unit -> unit
57

58
val flatten: loc -> 
59
  (Types.t -> bool -> Types.t) -> (Types.t -> bool -> Types.t)
60

61
62
63
64
65
66
67
  (** {2 Schema stuff} *)

  (** register a schema *)
val register_schema: string -> Schema_types.schema -> unit

  (** @return the validator for a Schema global element *)
val get_schema_validator: string * string -> Schema_validator.validator
68

69
  (** DEBUG ONLY *)
70

71
72
  (* return the type of a global schema element *)
val get_schema_type: string * string -> Types.descr
73
74
75
76
77



(* Operators *)

78
79
80
81
82
83
type type_fun = Types.t -> bool -> Types.t
val mk_unary_op: (string -> t -> int) ref
val typ_unary_op: (int -> loc -> type_fun -> type_fun) ref

val mk_binary_op: (string -> t -> int) ref
val typ_binary_op: (int -> loc -> type_fun -> type_fun -> type_fun) ref
84