1 (* Copyright (C) 2004-2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
33 | TermValue of NotationPt.term
34 | StringValue of ident_or_var
36 | OptValue of value option
37 | ListValue of value list
40 | TermType of int (* the level of the expected term *)
43 | OptType of value_type
44 | ListType of value_type
46 (** looked up value not found in environment *)
47 exception Value_not_found of string
49 (** looked up value has the wrong type
50 * parameters are value name and value type in environment *)
51 exception Type_mismatch of string * value_type
53 type declaration = string * value_type
54 type binding = string * (value_type * value)
57 val declaration_of_var: NotationPt.pattern_variable -> declaration
58 val value_of_term: NotationPt.term -> value
59 val term_of_value: value -> NotationPt.term
60 val well_typed: value_type -> value -> bool
62 val declarations_of_env: t -> declaration list
63 val declarations_of_term: NotationPt.term -> declaration list
64 val combine: declaration list -> value list -> t (** @raise Invalid_argument *)
66 (** {2 Environment lookup} *)
68 val lookup_value: t -> string -> value (** @raise Value_not_found *)
70 (** lookup_* functions below may raise Value_not_found and Type_mismatch *)
72 val lookup_term: t -> string -> NotationPt.term
73 val lookup_string: t -> string -> ident_or_var
74 val lookup_num: t -> string -> string
75 val lookup_opt: t -> string -> value option
76 val lookup_list: t -> string -> value list
78 val remove_name: t -> string -> t
79 val remove_names: t -> string list -> t
81 (** {2 Bindings mangling} *)
83 val opt_binding_some: binding -> binding (* v -> Some v *)
84 val opt_binding_none: binding -> binding (* v -> None *)
86 val opt_binding_of_name: declaration -> binding (* None binding *)
87 val list_binding_of_name: declaration -> binding (* [] binding *)
89 val opt_declaration: declaration -> declaration (* t -> OptType t *)
90 val list_declaration: declaration -> declaration (* t -> ListType t *)
92 (** given a list of environments bindings a set of names n_1, ..., n_k, returns
93 * a single environment where n_i is bound to the list of values bound in the
94 * starting environments *)
95 val coalesce_env: declaration list -> t list -> t