+let add_coercion (src,tgt,u,saturations,cpos) =
+ let f s t = eq_carr s src && eq_carr t tgt in
+ let where = List.filter (fun (s,t,_) -> f s t) !db in
+ let rest = List.filter (fun (s,t,_) -> not (f s t)) !db in
+ match where with
+ | [] -> db := (src,tgt,[u,1,saturations,cpos]) :: !db
+ | (src,tgt,l)::tl ->
+ assert (tl = []); (* not sure, this may be a feature *)
+ if List.exists (fun (x,_,_,_) -> UriManager.eq u x) l then
+ let l = List.map
+ (fun (x,n,x_saturations,x_cpos) as e ->
+ if UriManager.eq u x then
+ (* not sure, this may be a feature *)
+ (assert (x_saturations = saturations && x_cpos = cpos);
+ (x,n+1,saturations,cpos))
+ else e)
+ l
+ in
+ db := (src,tgt,l)::tl @ rest
+ else
+ db := (src,tgt,(u,1,saturations,cpos)::l)::tl @ rest
+;;