typer.mli 1.97 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
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
23
24
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
25

26
27
type env = Types.descr Env.t

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

val report_unused_branches : unit -> unit
  (* Issue warnings for unused branches *)
41
42
43

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

45
46
47
48
49
50
51
  (** {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
52

53
  (** DEBUG ONLY *)
54

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



(* Operators *)

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