+
+(* helpers ******************************************************************)
+
+let rec name err f = function
+ | Name (n, r) :: _ -> f n r
+ | _ :: tl -> name err f tl
+ | [] -> err ()
+
+let rec apix err f = function
+ | Apix i :: _ -> f i
+ | _ :: tl -> apix err f tl
+ | [] -> err ()
+
+let rec mark err f = function
+ | Mark i :: _ -> f i
+ | _ :: tl -> mark err f tl
+ | [] -> err ()
+
+let rec priv err f = function
+ | Priv :: _ -> f ()
+ | _ :: tl -> priv err f tl
+ | [] -> err ()
+
+let resolve err f name a =
+ let rec aux i = function
+ | Name (n, true) :: _ when n = name -> f i
+ | _ :: tl -> aux (succ i) tl
+ | [] -> err i
+ in
+ aux 0 a
+
+let xlate f xlate_term = function
+ | a, uri, Abst t ->
+ let f t = f (a, uri, Abst t) in xlate_term f t
+ | a, uri, Abbr t ->
+ let f t = f (a, uri, Abbr t) in xlate_term f t