(***********************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* List.fold_right (fun x -> f (in_gen t x)) (Obj.magic l) | _ -> failwith "Genarg: not a list0" let fold_list1 f = function | (List1ArgType t as u, l) -> List.fold_right (fun x -> f (in_gen t x)) (Obj.magic l) | _ -> failwith "Genarg: not a list1" let fold_opt f a = function | (OptArgType t as u, l) -> (match Obj.magic l with | None -> a | Some x -> f (in_gen t x)) | _ -> failwith "Genarg: not a opt" let fold_pair f = function | (PairArgType (t1,t2) as u, l) -> let (x1,x2) = Obj.magic l in f (in_gen t1 x1) (in_gen t2 x2) | _ -> failwith "Genarg: not a pair" let app_list0 f = function | (List0ArgType t as u, l) -> let o = Obj.magic l in (u, Obj.repr (List.map (fun x -> out_gen t (f (in_gen t x))) o)) | _ -> failwith "Genarg: not a list0" let app_list1 f = function | (List1ArgType t as u, l) -> let o = Obj.magic l in (u, Obj.repr (List.map (fun x -> out_gen t (f (in_gen t x))) o)) | _ -> failwith "Genarg: not a list1" let app_opt f = function | (OptArgType t as u, l) -> let o = Obj.magic l in (u, Obj.repr (option_app (fun x -> out_gen t (f (in_gen t x))) o)) | _ -> failwith "Genarg: not an opt" let app_pair f1 f2 = function | (PairArgType (t1,t2) as u, l) -> let (o1,o2) = Obj.magic l in let o1 = out_gen t1 (f1 (in_gen t1 o1)) in let o2 = out_gen t2 (f2 (in_gen t2 o2)) in (u, Obj.repr (o1,o2)) | _ -> failwith "Genarg: not a pair" let unquote x = x type an_arg_of_this_type = Obj.t let in_generic t x = (t, Obj.repr x)