1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openProofviewopenTac2ffi(* Local shortcuts. *)typev=Tac2val.valexprtype'rof_v=v->'rtype'rto_v='r->vtype'awith_env=Environ.env->Evd.evar_map->'a(* We use two levels of GADT to get rid of the third type parameter, which has
to be give for this type definition to be accepted. If we remove it, we get
an error: "a type variable cannot be deduced from the type parameters". *)type(_,_,_)spec_aux=|T:'rto_v->(vtactic,'rtactic,'r)spec_aux|V:'rto_v->(vtactic,'r,'r)spec_aux|E:'rto_v->(vtactic,'rwith_env,'r)spec_aux|G:'rto_v->(vtactic,Goal.t->'r,'r)spec_aux|F:'aof_v*('t,'f,'r)spec_aux->(v->'t,'a->'f,'r)spec_auxtype(_,_)spec=S:('v,'f,'r)spec_aux->('v,'f)spec[@@unboxed]lettac:typer.rrepr->(vtactic,rtactic)spec=funr->S(T(repr_ofr))lettac':typer.rto_v->(vtactic,rtactic)spec=funtr->S(Ttr)letret:typer.rrepr->(vtactic,r)spec=funr->S(V(repr_ofr))letret':typer.rto_v->(vtactic,r)spec=funtr->S(Vtr)leteret:typer.rrepr->(vtactic,rwith_env)spec=funr->S(E(repr_ofr))leteret':typer.rto_v->(vtactic,rwith_env)spec=funtr->S(Etr)letgret:typer.rrepr->(vtactic,Goal.t->r)spec=funr->S(G(repr_ofr))letgret':typer.rto_v->(vtactic,Goal.t->r)spec=funtr->S(Gtr)let(@->):typeatf.arepr->(t,f)spec->(v->t,a->f)spec=funr(Sar)->S(F(repr_tor,ar))let(@-->):typeatf.aof_v->(t,f)spec->(v->t,a->f)spec=funof_v(Sar)->S(F(of_v,ar))letrecinterp_spec:typevf.(v,f)spec->f->v=fun(Sar)f->letopenProofview.Notationsinmatcharwith|Ttr->f>>=funv->tclUNIT(trv)|Vtr->tclUNIT(trf)|Etr->tclENV>>=fune->tclEVARMAP>>=funs->tclUNIT(tr(fes))|Gtr->Goal.enter_one@@fung->tclUNIT(tr(fg))|F(tr,ar)->funv->interp_spec(Sar)(f(trv))letrecarity_of:typevf.(v,f)spec->vTac2val.arity=fun(Sar)->matcharwith|F(_,T_)->Tac2val.arity_one|F(_,V_)->Tac2val.arity_one|F(_,E_)->Tac2val.arity_one|F(_,G_)->Tac2val.arity_one|F(_,ar)->Tac2val.arity_suc(arity_of(Sar))|_->invalid_arg"Tac2def.arity_of: not a function spec"letdefine:typevf._->(v,f)spec->f->unit=funnarv->letv=matcharwith|S(Vtr)->trv|S(F_)->letcl=Tac2val.mk_closure(arity_ofar)(interp_specarv)inTac2ffi.of_closurecl|_->invalid_arg"Tac2def.define: not a pure value"inTac2env.define_primitivenv