typer.mli 2.32 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 env
val empty_env: env
val get_ns_table : env -> Ns.table
16

17
val enter_ns : U.t -> Ns.t -> env -> env
18

19 20 21
val enter_value: id -> Types.t -> env -> env
val enter_values: (id * Types.t) list -> env -> env
val find_value: id -> env -> Types.t
22

23 24 25
val enter_type: id -> Types.t -> env -> env
val enter_types: (id * Types.t) list -> env -> env
val find_type: id -> env -> Types.t
26

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

31 32 33 34 35 36
val dump_types: Format.formatter -> env -> unit
val dump_ns: Format.formatter -> env -> unit
val set_ns_table_for_printer: env -> unit

val expr: env -> Ast.pexpr -> fv * Typed.texpr
val let_decl : env -> Ast.ppat -> Ast.pexpr -> Typed.let_decl
37

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

val report_unused_branches : unit -> unit
  (* Issue warnings for unused branches *)
51
val clear_unused_branches : unit -> unit
52 53

val flatten: Location.loc -> 
54
  (Types.t -> bool -> Types.t) -> (Types.t -> bool -> Types.t)
55

56 57 58 59 60 61 62
  (** {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
63

64
  (** DEBUG ONLY *)
65

66 67
  (* return the type of a global schema element *)
val get_schema_type: string * string -> Types.descr
68 69 70 71 72



(* Operators *)

73 74
val register_unary_op: string -> (env -> Typed.unary_op) -> unit
val register_binary_op : string -> (env -> Typed.binary_op) -> unit
75