aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPierre Roux2020-09-03 13:25:00 +0200
committerPierre Roux2020-11-05 00:20:19 +0100
commite728a1ef0f8b5fdc4b1815a7d0349c67db15f9b4 (patch)
tree2a809813e374246465eb693bf444bffab25fd13c /doc
parent036117fa4992debb42e8346a48f6259f504793d3 (diff)
[numeral notation] Add support for parameterized inductives
Diffstat (limited to 'doc')
-rw-r--r--doc/sphinx/user-extensions/syntax-extensions.rst28
1 files changed, 26 insertions, 2 deletions
diff --git a/doc/sphinx/user-extensions/syntax-extensions.rst b/doc/sphinx/user-extensions/syntax-extensions.rst
index 4c6d300b13..60fbd68687 100644
--- a/doc/sphinx/user-extensions/syntax-extensions.rst
+++ b/doc/sphinx/user-extensions/syntax-extensions.rst
@@ -1608,6 +1608,12 @@ Number notations
function application, constructors, inductive type families,
sorts, and primitive integers) will be considered for printing.
+ .. note::
+ Number notations for parameterized inductive types can be
+ added by declaring an :ref:`abbreviation <Abbreviations>`
+ for the inductive which instantiates all parameters. See
+ example below.
+
:n:`via @qualid__ind mapping [ {+, @qualid__constant => @qualid__constructor } ]`
When using this option, :n:`@qualid__type` no
longer needs to be an inductive type and is instead mapped to the
@@ -1847,6 +1853,24 @@ Number notations
Check 2 : Fin.t 2.
+ .. example:: Number Notation with a parameterized inductive type
+
+ .. coqtop:: in reset
+
+ Definition of_uint u : list unit :=
+ let fix f n := match n with O => nil | S n => cons tt (f n) end in
+ f (Nat.of_num_uint u).
+ Definition to_uint (l : list unit) := Nat.to_num_uint (length l).
+
+ The parameter :g:`unit` for the parameterized inductive type
+ :g:`list` is given through an :ref:`abbreviation
+ <Abbreviations>`.
+
+ .. coqtop:: in
+
+ Notation list_unit := (list unit) (only parsing).
+ Number Notation list_unit of_uint to_uint : nat_scope.
+
.. _string-notations:
String notations
@@ -1917,8 +1941,8 @@ The following errors apply to both string and number notations:
.. exn:: @type is not an inductive type.
- String and number notations can only be declared for inductive types with no
- arguments. Declare numeral notations for non-inductive types using :n:`@number_via`.
+ String and number notations can only be declared for inductive types.
+ Declare number notations for non-inductive types using :n:`@number_via`.
.. exn:: Cannot interpret in @scope_name because @qualid could not be found in the current environment.