From 2f5fefcd76259d5e0aee5ef5076ae4c4dd662ec1 Mon Sep 17 00:00:00 2001 From: Talia Ringer Date: Fri, 7 Jun 2019 06:59:16 -0400 Subject: Update, expand, and document plugin tutorial 2 --- doc/plugin_tutorial/tuto2/src/counter.ml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 doc/plugin_tutorial/tuto2/src/counter.ml (limited to 'doc/plugin_tutorial/tuto2/src/counter.ml') diff --git a/doc/plugin_tutorial/tuto2/src/counter.ml b/doc/plugin_tutorial/tuto2/src/counter.ml new file mode 100644 index 0000000000..8721090d42 --- /dev/null +++ b/doc/plugin_tutorial/tuto2/src/counter.ml @@ -0,0 +1,22 @@ +(* + * This file defines our counter, which we use in the Count command. + *) + +(* + * Our counter is simply a reference called "counter" to an integer. + * + * Summary.ref behaves like ref, but also registers a summary to Coq. + *) +let counter = Summary.ref ~name:"counter" 0 + +(* + * We can increment our counter: + *) +let increment () = + counter := succ !counter + +(* + * We can also read the value of our counter: + *) +let value () = + !counter -- cgit v1.2.3