From 3b8acc174490878a3d0c9345e34a0ecb1d3abd66 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Mon, 7 Nov 2016 13:27:16 +0100 Subject: Typeclasses API using EConstr. --- engine/termops.ml | 9 +++++++++ engine/termops.mli | 2 ++ 2 files changed, 11 insertions(+) (limited to 'engine') diff --git a/engine/termops.ml b/engine/termops.ml index f191e2dc12..e5db3c085b 100644 --- a/engine/termops.ml +++ b/engine/termops.ml @@ -818,6 +818,15 @@ let is_section_variable id = try let _ = Global.lookup_named id in true with Not_found -> false +let global_of_constr sigma c = + let open Globnames in + match EConstr.kind sigma c with + | Const (c, u) -> ConstRef c, u + | Ind (i, u) -> IndRef i, u + | Construct (c, u) -> ConstructRef c, u + | Var id -> VarRef id, Univ.Instance.empty + | _ -> raise Not_found + let isGlobalRef sigma c = match EConstr.kind sigma c with | Const _ | Ind _ | Construct _ | Var _ -> true diff --git a/engine/termops.mli b/engine/termops.mli index 4becca907c..c90fdf9c2e 100644 --- a/engine/termops.mli +++ b/engine/termops.mli @@ -264,6 +264,8 @@ val dependency_closure : env -> Evd.evar_map -> Context.Named.t -> Id.Set.t -> I (** Test if an identifier is the basename of a global reference *) val is_section_variable : Id.t -> bool +val global_of_constr : Evd.evar_map -> EConstr.constr -> Globnames.global_reference puniverses + val isGlobalRef : Evd.evar_map -> EConstr.t -> bool val is_template_polymorphic : env -> Evd.evar_map -> EConstr.t -> bool -- cgit v1.2.3