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

13
14
15
type tenv
val get_ns_table : tenv -> Ns.table

16
val register_global_types : (U.t * Ast.ppat) list -> unit
17
val register_global_ns : U.t -> Ns.t -> unit
18
val dump_global_types: Format.formatter -> unit
19
val dump_global_ns: Format.formatter -> unit
20

21
22
val set_ns_table_for_printer: unit -> unit

23
24
25
26
val typ : Ast.ppat -> Typed.ttyp
val pat : Ast.ppat -> Typed.tpat
val expr: Ast.pexpr -> fv * Typed.texpr
val let_decl : Ast.ppat -> Ast.pexpr -> Typed.let_decl
27

28
29
type env = Types.descr Env.t

30
val type_check: 
31
  env -> Typed.texpr -> Types.descr -> bool -> Types.descr
32
  (* [type_check env e t precise] checks that expression [e] 
33
34
35
     has type [t] under typing environment [env]; if [precise=true], 
     also returns a possible more precise type for [e].
  *)
36
val type_let_decl: env -> Typed.let_decl -> (id * Types.descr) list
37
     
38
val type_rec_funs: env -> Typed.texpr list -> (id * Types.descr) list
39
  (* Assume that all the expressions are Abstractions *)
40
41
42

val report_unused_branches : unit -> unit
  (* Issue warnings for unused branches *)
43
val clear_unused_branches : unit -> unit
44
45
46

val flatten: Location.loc -> 
  (Types.descr -> bool -> Types.descr) -> (Types.descr -> bool -> Types.descr)
47

48
49
50
51
52
53
54
  (** {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
55

56
  (** DEBUG ONLY *)
57

58
59
  (* return the type of a global schema element *)
val get_schema_type: string * string -> Types.descr
60
61
62
63
64
65
66
67



(* Operators *)

val register_unary_op: string -> (tenv -> Typed.unary_op) -> unit
val register_binary_op : string -> (tenv -> Typed.binary_op) -> unit