aboutsummaryrefslogtreecommitdiff
path: root/doc/plugin_tutorial/tuto1/src/simple_print.ml
diff options
context:
space:
mode:
authorGaëtan Gilbert2019-01-07 13:24:14 +0100
committerGaëtan Gilbert2019-01-08 16:41:01 +0100
commitfde557d9e92d2ddd3c79d8a620f2cb33ce64a49f (patch)
tree1b8a0e216119c908d50277432221ab06805a2ac9 /doc/plugin_tutorial/tuto1/src/simple_print.ml
parent8c040974facb733682d24c488dc89941671f4ab7 (diff)
parent168a13dab1c9987f592994150997e692d4d7e40b (diff)
Add 'doc/plugin_tutorial/' from commit '168a13dab1c9987f592994150997e692d4d7e40b'
git-subtree-dir: doc/plugin_tutorial git-subtree-mainline: 8c040974facb733682d24c488dc89941671f4ab7 git-subtree-split: 168a13dab1c9987f592994150997e692d4d7e40b
Diffstat (limited to 'doc/plugin_tutorial/tuto1/src/simple_print.ml')
-rw-r--r--doc/plugin_tutorial/tuto1/src/simple_print.ml17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/plugin_tutorial/tuto1/src/simple_print.ml b/doc/plugin_tutorial/tuto1/src/simple_print.ml
new file mode 100644
index 0000000000..cfc38ff9c9
--- /dev/null
+++ b/doc/plugin_tutorial/tuto1/src/simple_print.ml
@@ -0,0 +1,17 @@
+(* A more advanced example of how to explore the structure of terms of
+ type constr is given in the coq-dpdgraph plugin. *)
+
+let simple_body_access gref =
+ match gref with
+ | Globnames.VarRef _ ->
+ failwith "variables are not covered in this example"
+ | Globnames.IndRef _ ->
+ failwith "inductive types are not covered in this example"
+ | Globnames.ConstructRef _ ->
+ failwith "constructors are not covered in this example"
+ | Globnames.ConstRef cst ->
+ let cb = Environ.lookup_constant cst (Global.env()) in
+ match Global.body_of_constant_body cb with
+ | Some(e, _) -> e
+ | None -> failwith "This term has no value"
+