--- /dev/null
+(*
+ ||M|| This file is part of HELM, an Hypertextual, Electronic
+ ||A|| Library of Mathematics, developed at the Computer Science
+ ||T|| Department, University of Bologna, Italy.
+ ||I||
+ ||T|| HELM is free software; you can redistribute it and/or
+ ||A|| modify it under the terms of the GNU General Public License
+ \ / version 2 or (at your option) any later version.
+ \ / This software is distributed as is, NO WARRANTY.
+ V_______________________________________________________________ *)
+
+type uri = NUri.uri
+type id = Aut.id
+
+type bind = Void (* exclusion *)
+ | Abst of term (* abstraction *)
+ | Abbr of term (* abbreviation *)
+
+and term = Sort of int (* hierarchy index *)
+ | LRef of int (* location *)
+ | GRef of uri (* reference *)
+ | Cast of term * term (* type, term *)
+ | Appl of term * term (* argument, function *)
+ | Bind of int * id * bind * term (* location, name, binder, scope *)
+
+type obj = int * uri * bind (* age, uri, binder, contents *)
+
+type item = obj option
+
+type context = (int * id * bind) list (* location, name, binder *)
+
+type message = (context, term) Log.item list
+
+(* Currified constructors ***************************************************)
+
+let abst w = Abst w
+
+let abbr v = Abbr v
+
+let lref i = LRef i
+
+let cast u t = Cast (u, t)
+
+let appl u t = Appl (u, t)
+
+let bind l id b t = Bind (l, id, b, t)
+
+let bind_abst l id u t = Bind (l, id, Abst u, t)
+
+let bind_abbr l id v t = Bind (l, id, Abbr v, t)
+
+(* location handling functions **********************************************)
+
+let location = ref 0
+
+let new_location () = let loc = !location in incr location; loc
+
+(* context handling functions ***********************************************)
+
+let empty_context = []
+
+let push f es l id b =
+ let c = (l, id, b) :: es in f c
+
+let append f es1 es2 =
+ f (List.append es2 es1)
+
+let map f map es =
+ Cps.list_map f map es
+
+let contents f es = f es
+
+let get f es i =
+ let rec aux = function
+ | [] -> f None
+ | (l, id, b) :: tl -> if l = i then f (Some (id, b)) else aux tl
+ in
+ aux es