aboutsummaryrefslogtreecommitdiff
path: root/doc/plugin_tutorial/tuto2/src/counter.ml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/plugin_tutorial/tuto2/src/counter.ml')
-rw-r--r--doc/plugin_tutorial/tuto2/src/counter.ml22
1 files changed, 22 insertions, 0 deletions
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