typer.mli 2.2 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 from_comp_unit: (Types.CompUnit.t -> t) ref

18 19
val empty_env: t
val get_ns_table : t -> Ns.table
20

21
val enter_ns : U.t -> Ns.t -> t -> t
22
val enter_cu : U.t -> Types.CompUnit.t -> t -> t 
23

24 25 26
val enter_value: id -> Types.t -> t -> t
val enter_values: (id * Types.t) list -> t -> t
val find_value: id -> t -> Types.t
27
val iter_values: t -> (id -> Types.t -> unit) -> unit
28

29 30 31
val enter_type: id -> Types.t -> t -> t
val enter_types: (id * Types.t) list -> t -> t
val find_type: id -> t -> Types.t
32

33 34 35
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
36

37
val dump_types: Format.formatter -> t -> unit
38
val dump_type: Format.formatter -> t -> U.t -> unit
39
val dump_schema_type:
40
  Format.formatter -> (Schema_types.component_kind * U.t * U.t) -> unit
41 42 43 44

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

45 46 47 48 49 50 51 52
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
53
  (* Assume that all the expressions are Abstractions *)
54

55 56


57

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

61
(** {2 Schema stuff} *)
62

63
val register_schema: U.t -> Schema_types.schema -> unit
64
val is_registered_schema: U.t -> bool
65 66
val get_schema: U.t -> Schema_types.schema  (** lookup schema by name *)
val get_schema_names: unit -> U.t list  (** registered schema names *)
67

68 69
(* Operators *)

70 71 72 73 74 75
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
76